public static void Configure(CommandLineApplication app, CommandLineOptions options, IConsole console) { // description app.Description = "Deposits to an asset account"; app.ExtendedHelpText = $"{Environment.NewLine}Use 'accounts deposit -i' to enter interactive mode{Environment.NewLine}"; // arguments var argumentAssetAccountId = app.Argument("account", "The asset account id to deposit", false); var argumentReferenceId = app.Argument("reference", "The unique reference identifier for this transaction", false); var argumentAmount = app.Argument("amount", "The amount to deposit", false); var argumentSettlementCurrency = app.Argument("currency", "The ISO currency code for settlement currency", false); // options var optionInteractive = app.Option("-i|--interactive", "Enters interactive mode", CommandOptionType.NoValue); var optionReferenceText = app.Option("-t|--info", "The reference text which describes about this transaction", CommandOptionType.SingleValue); // action (for this command) app.OnExecute( () => { if ((string.IsNullOrWhiteSpace(argumentAssetAccountId.Value) || string.IsNullOrWhiteSpace(argumentReferenceId.Value) || string.IsNullOrWhiteSpace(argumentSettlementCurrency.Value) || string.IsNullOrWhiteSpace(argumentAmount.Value)) && !optionInteractive.HasValue()) { app.ShowVersionAndHelp(); return; } if (!decimal.TryParse(argumentAmount.Value, out decimal amount) && !optionInteractive.HasValue()) { app.ShowVersionAndHelp(); return; } var reporter = new ConsoleReporter(console, options.Verbose.HasValue(), false); var helper = new DepositHelper(); var deposit = new DepositAssetAccount { AssetAccountId = argumentAssetAccountId.Value, ReferenceId = argumentReferenceId.Value, ReferenceText = optionReferenceText.Value(), Amount = amount, SettlementCurrency = argumentSettlementCurrency.Value, Precision = string.IsNullOrEmpty(argumentAmount.Value) ? 0 : helper.GetPrecision(argumentAmount.Value) }; reporter.Verbose("Prototype deposit (from command line arguments):"); reporter.Verbose(JsonConvert.SerializeObject(deposit)); if (!helper.IsValid(deposit) || optionInteractive.HasValue()) { try { deposit = helper.GetValid(deposit); } catch (NotSupportedException ex) { throw new CommandParsingException(app, $"Operation Aborted. {ex.Message}", ex); } reporter.Verbose("Validated deposit (from interactive console):"); reporter.Verbose(JsonConvert.SerializeObject(deposit)); } options.Command = new DepositAssetAccountCommand { deposit = deposit }; }); }