Tyrrrz / CliFx

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

Cannot pass negative doubles #88

Closed brianharwell closed 3 years ago

brianharwell commented 3 years ago

I have a simple command...

[Command("calculate")]
    public class Calculate : ICommand
    {
        [CommandParameter(0, Name = "Latitude")]
        public double Latitude { get; set; }

        [CommandParameter(1, Name = "Longitude")]
        public double Longitude { get; set; }

        public ValueTask ExecuteAsync(IConsole console)
        {
            System.Console.WriteLine($"Latitude: {Latitude}");
            System.Console.WriteLine($"Longitude: {Longitude}");

            return default;
        }
    }

If I pass positive values it works...

.\Console.exe calculate 1 3
Latitude: 1
Longitude: 3

.\Console.exe calculate 1.6675 3.7655676
Latitude: 1.6675
Longitude: 3.7655676

If I pass negative numbers it fails...

.\Console.exe calculate -1.6675 -3.7655676
Missing value for parameter <Latitude>.
brianharwell commented 3 years ago

Even attempting to pass as strings fails...

.\Console.exe calculate "-1.6675" "-3.7655676"
Missing value for parameter <Latitude>.
adambajguz commented 3 years ago

hi, this is sth I have fixed in Typin. @Tyrrrz feel free to copy my idea.

PS. develop branch has a 3.0 developer preview version that has a much cleaner code than on master.

brianharwell commented 3 years ago

Sweet thanks!

Tyrrrz commented 3 years ago

Np. I'll try to release a new version next week

brianharwell commented 3 years ago

@Tyrrrz Would you please cut a release with this fix?

Tyrrrz commented 3 years ago

@brianharwell v1.6 should already have it

brianharwell commented 3 years ago

@Tyrrrz i thought it might so I updated and the parsing still fails

Tyrrrz commented 3 years ago

@brianharwell can you share a command that fails? maybe i missed some edge case

brianharwell commented 3 years ago

@Tyrrrz It's good. The mistake was on my end. Thanks!

Tyrrrz commented 3 years ago

@brianharwell glad to hear!