Added password entry support
This commit is contained in:
parent
4babd13dc7
commit
5da2776f5d
|
@ -72,6 +72,10 @@ Once the first none-empty line is unrecognized (no command found), the parser wi
|
||||||
: Prompts the user for the input of `<variablename>`. If the value has been given in a previous run, it is suggested as default value so the user can simply accept the "last" value. This eases re-runs of the same profile with only minor (or no) changes.
|
: Prompts the user for the input of `<variablename>`. If the value has been given in a previous run, it is suggested as default value so the user can simply accept the "last" value. This eases re-runs of the same profile with only minor (or no) changes.
|
||||||
This can be repeated multiple times.
|
This can be repeated multiple times.
|
||||||
|
|
||||||
|
`Ask#<variablename>`
|
||||||
|
: Prompts the user for the hidden input of `<variablename>`. This can be used to input passwords. These values are not persisted and therefore no default values are suggested.
|
||||||
|
This can be repeated multiple times.
|
||||||
|
|
||||||
`Header <http header>`
|
`Header <http header>`
|
||||||
: Sets the given http header for the request.
|
: Sets the given http header for the request.
|
||||||
This can be repeated multiple times.
|
This can be repeated multiple times.
|
||||||
|
|
|
@ -149,10 +149,11 @@ end;
|
||||||
function TRestemplateApplication.ProcessCommand(ALine: String): Boolean;
|
function TRestemplateApplication.ProcessCommand(ALine: String): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if AnsiStartsStr('Ask ', ALine) then
|
//The first char after "Ask" is treated as "mode". "#" means password.
|
||||||
|
if AnsiStartsStr('Ask', ALine) then
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
CmdAskUser(Copy(ALine, 5, Length(ALine)));
|
CmdAskUser(Copy(ALine, 4, Length(ALine)));
|
||||||
end else
|
end else
|
||||||
if AnsiStartsStr('Header ', ALine) then
|
if AnsiStartsStr('Header ', ALine) then
|
||||||
begin
|
begin
|
||||||
|
@ -191,16 +192,34 @@ end;
|
||||||
|
|
||||||
procedure TRestemplateApplication.CmdAskUser(AName: String);
|
procedure TRestemplateApplication.CmdAskUser(AName: String);
|
||||||
var
|
var
|
||||||
|
mode: TPromptMode;
|
||||||
value, default: String;
|
value, default: String;
|
||||||
begin
|
begin
|
||||||
|
if Length(AName) < 2 then
|
||||||
|
raise Exception.Create('Asking without variable!');
|
||||||
|
|
||||||
|
if AName[1] <> ' ' then
|
||||||
|
mode := pmPassword
|
||||||
|
else
|
||||||
|
mode := pmNormal;
|
||||||
|
|
||||||
|
AName := Copy(AName, 2, Length(AName));
|
||||||
|
|
||||||
|
if mode = pmNormal then
|
||||||
|
begin
|
||||||
default := FSessionIni.ReadString(FTemplateName, AName, '');
|
default := FSessionIni.ReadString(FTemplateName, AName, '');
|
||||||
value := Prompt(AName, default);
|
value := Prompt(AName, default);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
value := Prompt(AName, mode);
|
||||||
|
end;
|
||||||
|
|
||||||
if value = '' then
|
if value = '' then
|
||||||
Halt(3); //Cancelled
|
Halt(3); //Cancelled
|
||||||
|
|
||||||
FParser.Fields.Add(AName, value);
|
FParser.Fields.Add(AName, value);
|
||||||
|
|
||||||
|
if mode = pmNormal then
|
||||||
FSessionIni.WriteString(FTemplateName, AName, value);
|
FSessionIni.WriteString(FTemplateName, AName, value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue