public async Task <object> Execute(ArgumentSyntax syntax) { var serverUriParam = syntax.GetActiveArguments() .Where(p => p.Name == ParamServer) .OfType <Argument <Uri> >() .First(); if (!serverUriParam.IsSpecified) { syntax.ReportError(string.Format(Strings.ErrorOptionMissing, ParamServer)); } var ctx = contextFactory.Invoke(serverUriParam.Value, null); logger.Debug("Loading directory from '{0}'", serverUriParam.Value); var directory = await ctx.GetDirectory(); await userSettings.SetDefaultServer(serverUriParam.Value); return(new { location = serverUriParam.Value, resource = directory, }); }
public static int Main(string[] args) { int result = 0; try { ICommand[] commands = { new BuildCommand(), new CopyImagesCommand(), new CopyAcrImagesCommand(), new GenerateBuildMatrixCommand(), new GenerateTagsReadmeCommand(), new PublishManifestCommand(), new PublishMcrReadmesCommand(), new UpdateReadmeCommand(), new UpdateVersionsCommand(), new ValidateImageSizeCommand(), }; ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => { foreach (ICommand command in commands) { command.Options.ParseCommandLine(syntax); } }); // Workaround for https://github.com/dotnet/corefxlab/issues/1689 foreach (Argument arg in argSyntax.GetActiveArguments()) { if (arg.IsParameter && !arg.IsSpecified) { Logger.WriteError($"error: `{arg.Name}` must be specified."); Environment.Exit(1); } } if (argSyntax.ActiveCommand != null) { // Capture the Docker version and info in the output. ExecuteHelper.Execute(fileName: "docker", args: "version", isDryRun: false); ExecuteHelper.Execute(fileName: "docker", args: "info", isDryRun: false); ICommand command = commands.Single(c => c.Options == argSyntax.ActiveCommand.Value); command.LoadManifest(); command.ExecuteAsync().Wait(); } } catch (Exception e) { Logger.WriteError(e.ToString()); result = 1; } return(result); }
public static int Main(string[] args) { int result = 0; try { ICommand[] commands = Container.GetExportedValues <ICommand>().ToArray(); ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => { foreach (ICommand command in commands) { command.Options.ParseCommandLine(syntax); } }); // Workaround for https://github.com/dotnet/corefxlab/issues/1689 foreach (Argument arg in argSyntax.GetActiveArguments()) { if (arg.IsParameter && !arg.IsSpecified) { Logger.WriteError($"error: `{arg.Name}` must be specified."); Environment.Exit(1); } } if (argSyntax.ActiveCommand != null) { // Capture the Docker version and info in the output. ExecuteHelper.Execute(fileName: "docker", args: "version", isDryRun: false); ExecuteHelper.Execute(fileName: "docker", args: "info", isDryRun: false); ICommand command = commands.Single(c => c.Options == argSyntax.ActiveCommand.Value); if (command is IManifestCommand manifestCommand) { manifestCommand.LoadManifest(); } command.ExecuteAsync().Wait(); } } catch (Exception e) { Logger.WriteError(e.ToString()); result = 1; } return(result); }
public void Parse(string[] args) { ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => { IReadOnlyList <string> filters = Array.Empty <string>(); syntax.DefineOptionList( "filter", ref filters, "Filter to apply to repositories of the config json - wildcard chars * and ? supported"); Filters = filters; string configPath = null; syntax.DefineParameter( "config", ref configPath, "Path to the config json file"); ConfigPath = configPath; string gitUser = null; syntax.DefineParameter( "git-user", ref gitUser, "GitHub user used to make PR"); GitUser = gitUser; string gitEmail = null; syntax.DefineParameter( "git-email", ref gitEmail, "GitHub email used to make PR"); GitEmail = gitEmail; string gitAuthToken = null; syntax.DefineParameter( "git-auth-token", ref gitAuthToken, "GitHub authorization token used to make PR"); GitAuthToken = gitAuthToken; }); // Workaround for https://github.com/dotnet/corefxlab/issues/1689 foreach (Argument arg in argSyntax.GetActiveArguments()) { if (arg.IsParameter && !arg.IsSpecified) { Console.WriteLine($"error: `{arg.Name}` must be specified."); Environment.Exit(1); } } }
public static int Main(string[] args) { int result = 0; try { ICommand[] commands = { new BuildCommand(), new GenerateTagsReadmeCommand(), new PublishManifestCommand(), new UpdateReadmeCommand(), new UpdateVersionsCommand(), }; ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => { foreach (ICommand command in commands) { command.Options.ParseCommandLine(syntax); } }); // Workaround for https://github.com/dotnet/corefxlab/issues/1689 foreach (Argument arg in argSyntax.GetActiveArguments()) { if (arg.IsParameter && !arg.IsSpecified) { Console.Error.WriteLine($"error: `{arg.Name}` must be specified."); Environment.Exit(1); } } if (argSyntax.ActiveCommand != null) { ICommand command = commands.Single(c => c.Options == argSyntax.ActiveCommand.Value); command.LoadManifest(); command.ExecuteAsync().Wait(); } } catch (Exception e) { Console.WriteLine(e); result = 1; } return(result); }
public async Task <object> Execute(ArgumentSyntax syntax) { var(serverUri, key) = await ReadAccountKey(syntax, true, true); var domains = syntax.GetActiveArguments() .Where(a => a.Name == "domains") .OfType <ArgumentList <string> >() .Select(a => a.Value) .FirstOrDefault(); logger.Debug("Creating order from '{0}'.", serverUri); var acme = ContextFactory.Invoke(serverUri, key); var orderCtx = await acme.NewOrder(domains.ToArray()); return(new { location = orderCtx.Location, resource = await orderCtx.Resource(), }); }