Tyrrrz / CliFx

Class-first framework for building command-line interfaces
MIT License
1.5k stars 61 forks source link

Client fails when reading string with space #85

Closed kibernetik542 closed 4 years ago

kibernetik542 commented 4 years ago

I have checker for valid ssh key in my api.

When I try wrong values it works

user@Arzus-MBP TaikunCLI % dotnet run taikun check ssh --sshPublicKey ksddksmkd
Response Status Code: 400
{
    "status":400,
    "detail":"Invalid ssh key"
}

But good ssh key looks likessh-rsa AAAA.....

And in this case client can not read space based string and throws error

dotnet run taikun check ssh --sshPublicKey ssh-rsa AAAAB3NzaC1yc2EAAA....
Option --sshPublicKey expects a single value, but provided with multiple:
"ssh-rsa" "AAAAB3NzaC1yc2EAAAADAQABAAABAQDDT+a7kPwhnTgyF4ygu4D8Zk2GpwpM4qRxzGr48RSklgeL/iQZgiz2IFp6ns9k2pYiUII6J65fM4Im24uJqdIQiz2lg7mWHz5hVnKrFH3v8QvJRsxsQtW9iZYMt7WvmSxi5O5UUH+6oJX8ErpkjNGNL7DTia27n5iXD8pkpLr3lXKuQ2UX47IlXQGG/zG2zhZglsHhs/vn/ozYccNDg2zkyZzAnpK6gDRn6gBWgKjhmFSfXwsJOHpfvWAx7omC3cBEbBy8q5y4BLkwyElSV0UgxnhuMiEawMe7NnhCwRiI5+f+C8UYK2mvvuaUlFZ5Ph3JkFHS6JFLMllobPbe2VBB" "arzu@DESKTOP-H74NH8G"
Usage
  dotnet TaikunCLI.dll taikun check ssh --sshPublicKey <value> [options]

Options
* --sshPublicKey    
  -h|--help         Shows help text. 

P.S. Works fine in swagger, postman, curl etc.

My code looks like:

    [Command("taikun check ssh")]
    public class Ssh : BaseOperation, ICommand
    {
        public Ssh(ITaikunWebApi taikunClient) : base(taikunClient)
        { }

        [CommandOption("sshPublicKey", IsRequired = true)]
        public string SshPublicKey { get; set; }

        public async ValueTask ExecuteAsync(IConsole console)
        {
            var command = new SshKeyCommand { SshPublicKey = SshPublicKey };
            var httpResponse = await taikunClient.Checker.SshWithHttpMessagesAsync("1", command);
            await PrintResponse(console, httpResponse);
        }
    }
kibernetik542 commented 4 years ago

With putting double quote it worked