static int Main(string[] args) { var app = new CommandLineApplication(throwOnUnexpectedArg: false); RootCommand.Configure(app); return(app.Execute(args)); }
static int Main(string[] args) { var app = new CommandLineApplication(); RootCommand.Configure(app); return(app.Execute()); }
public static void Main(string[] args) { var app = new CommandLineApplication(); RootCommand.Configure(app); app.Execute(args); }
// ReSharper disable once FunctionRecursiveOnAllPaths public static void Main(string[] args) { CommandLineApplication app = new CommandLineApplication(); var root = new RootCommand(app); root.Configure(args); Main(Console.ReadLine()?.Split(' ')); }
private static string[] ArgumentExecutor(CommandLineApplication app, string[] args) { //Configure root command here. This creates a complete command line application instance. RootCommand.Configure(app); try { app.Execute(args); return(app.GetCommandNames()); } catch (Exception e) { Console.WriteLine(e.Message); } return(null); }
public static AppOptions Parse(string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } AppOptions options = new AppOptions(); CommandLineApplication app = new CommandLineApplication { Name = "Catutil", FullName = "App CLI" }; app.HelpOption("-?|-h|--help"); // app-level options RootCommand.Configure(app, options); int result = app.Execute(args); return(result != 0 ? null : options); }
public static CommandLineOptions Parse(string[] args) { var options = new CommandLineOptions(); var configurationReader = new ConfigurationReader(); var config = configurationReader.GetConfiguration(); options.Endpoint = config.Endpoint; options.LoginToken = config.LoginToken; var app = new CommandLineApplication { Name = "apollo", FullName = "Apollo CommandLine Interface" }; app.HelpOption("-h|--help"); var verboseSwitch = app.Option("--verbose", "Verbose Output", CommandOptionType.NoValue); var requestSwitch = app.Option("--showRequest", "Write request object to stdout", CommandOptionType.NoValue); var fullResultSwitch = app.Option("--fullResults", "Display full result object and not just command result", CommandOptionType.NoValue); RootCommand.Configure(app, options); var result = app.Execute(args); if (result != 0) { return(null); } options.Verbose = verboseSwitch.HasValue(); options.ShowRequest = requestSwitch.HasValue(); options.FullResults = fullResultSwitch.HasValue(); return(options); }
public static AppOptions Parse(string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } AppOptions options = new AppOptions(); CommandLineApplication app = new CommandLineApplication { Name = "embix", FullName = "Embedded indexing tool - " + Assembly.GetEntryAssembly().GetName().Version }; app.HelpOption("-?|-h|--help"); // app-level options RootCommand.Configure(app, options); int result = app.Execute(args); return(result != 0 ? null : options); }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) //.AddInMemoryCollection(new MySettings{WoTDirectory="C:\\Games\\World_Of_Tanks"}) .AddJsonFile("settings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); var settings = new MySettings(); configuration.Bind(settings); if (string.IsNullOrEmpty(settings.WoTDirectory)) { settings.WoTDirectory = "C:\\Games\\World_Of_Tanks"; } Application.InitializeInstance("key.json", settings.WoTDirectory); var cmdLineapp = new CommandLineApplication(); RootCommand.Configure(cmdLineapp); cmdLineapp.Execute(args); }
public static CommandLineOptions Parse(string[] args) { var options = new CommandLineOptions(); var app = new CommandLineApplication { Name = "dotnet FreeAgentSniper.dll", FullName = "Free Agent Sniper", ExtendedHelpText = "Tired of your league-mates waking up first thing Wednesday morning and sniping your free agents? " + "Don't want to waste your waiver priority on a mediocre player? Then use Free Agent Sniper to perform " + "add/drops for you as soon as players come off of waivers. Search for players, set up transactions, and " + "start the schedule to grab your players before your buddies wake up Wednesday morning!" }; app.HelpOption("-?|-h|--help"); RootCommand.Configure(app, options); var leagueOption = app.Option( "-l|--league", "Yahoo! league ID of the league to use for this command", CommandOptionType.SingleValue); var teamOption = app.Option( "-t|--team", "Yahoo! team ID for the team to use for this command", CommandOptionType.SingleValue); var refreshTokenOption = app.Option( "-r|--refresh-token", "OAuth 2.0 refresh token to use when authenticating this command", CommandOptionType.SingleValue); try { var result = app.Execute(args); // HACK: (JMB) Don't set options if they're set by a subcommand e.g. config if (!options.LeagueId.HasValue) { options.LeagueId = leagueOption.ValidateInt32Value(); } if (!options.TeamId.HasValue) { options.TeamId = teamOption.ValidateInt32Value(); } if (string.IsNullOrEmpty(options.RefreshToken)) { options.RefreshToken = refreshTokenOption.Value(); } var leagueIsValid = !leagueOption.HasValue() || options.LeagueId.HasValue; var teamIdIsValid = !teamOption.HasValue() || options.TeamId.HasValue; if (!leagueIsValid || !teamIdIsValid || result != 0) { return(null); } } catch (CommandParsingException cpe) { Console.Error.WriteLine(cpe.Message); return(null); } return(options); }