Example #1
0
        /// <inheritdoc />
        public Task RunAsync(string[] args)
        {
            CommandLineApplication cmdApp = new(throwOnUnexpectedArg : false);

            CommandOption grossAmount = cmdApp.Option(Messages.GrossAmountOption, Messages.GrossAmountHint, CommandOptionType.SingleValue);
            CommandOption currency    = cmdApp.Option(
                Messages.CurrencyOption,
                Messages.GetCurrencyHint(_appConfig.DefaultCurrencyCode),
                CommandOptionType.SingleValue);

            cmdApp.HelpOption(Messages.HelpOption);

            cmdApp.OnExecute(() =>
            {
                if (grossAmount.HasValue())
                {
                    Salary grossSalary = _salaryService.BuildSalary(grossAmount.Value(), currency.Value());
                    Salary netSalary   = _salaryService.GetNetSalary(grossSalary);

                    Console.WriteLine(Messages.GetResult(netSalary));
                }

                return(0);
            });

            cmdApp.Execute(args);
            return(Task.CompletedTask);
        }