Пример #1
0
            public ArgumentCommand Find(string[] arguments)
            {
                ArgumentCommand matchedArgumentCommand = null;
                int             argMatchedSize         = -1;

                this.argumentCommands.ForEach(c =>
                {
                    bool matched    = true;
                    int matchedSize = 0;
                    for (int n = 0; n < c.Arguments.Length; n++)
                    {
                        if (n > arguments.Length || !c.Arguments[n].Equals(arguments[n]))
                        {
                            matched = false;
                            break;
                        }
                        else
                        {
                            matchedSize++;
                        }
                    }

                    if (matched && matchedSize > argMatchedSize)
                    {
                        matchedArgumentCommand = c;
                        argMatchedSize         = matchedSize;
                    }
                });

                return(matchedArgumentCommand);
            }
Пример #2
0
        static void Main(string[] args)
        {
            commands.Create("Local operations (no network communication)")
            .Add(new EncryptCommand(), "-e")
            .Add(new DecryptCommand(), "-d")
            .Add(new HashEmailCommand(), "-h", "-e")
            .Add(new HashPhoneCommand(), "-h", "-p")
            .Add(new GenerateKeyPairCommand(), "-g")
            .Add(new DerivePublicKeyCommand(), "-p");

            commands.Create("Network operations")
            .Add(new SendSimpleMessageCommand(), "-s")
            .Add(new SendE2ETextMessageCommand(), "-S")
            .Add(new SendE2EImageMessageCommand(), "-S", "-i")
            .Add(new SendE2EFileMessageCommand(), "-S", "-f")
            .Add(new IDLookupByEmailCommand(), "-l", "-e")
            .Add(new IDLookupByPhoneNoCommand(), "-l", "-p")
            .Add(new FetchPublicKeyCommand(), "-l", "-k")
            .Add(new CapabilityCommand(), "-c")
            .Add(new DecryptAndDownloadCommand(), "-D")
            .Add(new CreditsCommand(), "-C");

            ArgumentCommand argumentCommand = commands.Find(args);

            if (argumentCommand == null)
            {
                usage(args.Length == 1 && args[0].Equals("html"));
            }
            else
            {
                argumentCommand.run(args);
            }
        }
 public ViewDesigns()
 {
     Navigator   = Navigator.Instance;
     Rooms       = LoadRooms();
     EditCommand = new ArgumentCommand <Design>(
         design => {
         Navigator.Push(new DesignEditorView(design));
         ;
     }
         );
     DeleteCommand    = new ArgumentCommand <Design>(DeleteDesign);
     CancelCommand    = new BasicCommand(ClosePopup);
     AddDesignCommand = new BasicCommand(AddDesign);
     ReloadCommand    = new BasicCommand(Reload);
     OpenPopup        = new BasicCommand(
         () => {
         IsAdding = true;
         OnPropertyChanged();
     }
         );
     //Om te voorkomen dat unit tests falen
     if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
     {
         RenderDesigns();
         MessageQueue = new SnackbarMessageQueue();
     }
 }
Пример #4
0
        public void ParseCommandLine(ArgumentSyntax syntax)
        {
            ArgumentCommand command = syntax.DefineCommand(GetCommandName(), this);

            command.Help = CommandHelp;
            DefineOptions(syntax);
            DefineParameters(syntax);
        }
 public RoomTemplate()
 {
     // submit command van submitknop
     Submit = new BasicCommand(SubmitRoom);
     // bind het templatecommand van de templateknoppen
     TemplateButton = new ArgumentCommand <int>(SetTemplate);
     MessageQueue   = new SnackbarMessageQueue();
 }
Пример #6
0
 public ViewRooms()
 {
     GotoRoomTemplate = new PageCommand(() => new RoomTemplateView());
     GotoRoomEditor   = new PageCommand(() => new RoomEditorView());
     DeleteCommand    = new ArgumentCommand <int>(DeleteRoom);
     UpdateCommand    = new ArgumentCommand <int>(UpdateRoom);
     MessageQueue     = new SnackbarMessageQueue();
     Reload();
 }
Пример #7
0
 public RoomEditor()
 {
     GridLines           = new List <Line>();
     RectangleDictionary = new Dictionary <Position, Rectangle>();
     Submit           = new BasicCommand(SubmitRoom);
     MouseOverCommand = new ArgumentCommand <MouseEventArgs>(e => MouseMove(e.OriginalSource, e));
     MouseDownCommand = new ArgumentCommand <MouseButtonEventArgs>(e => MouseClick(e.OriginalSource, e));
     AddDoors         = new BasicCommand(AddDoorsClick);
     AddWindows       = new BasicCommand(AddWindowsClick);
     Editor           = new Canvas();
     MessageQueue     = new SnackbarMessageQueue();
     Reload();
 }
Пример #8
0
        public virtual void ParseCommandLine(ArgumentSyntax syntax)
        {
            ArgumentCommand command = syntax.DefineCommand(CommandName, this);

            command.Help = CommandHelp;

            bool isDryRun = false;

            syntax.DefineOption("dry-run", ref isDryRun, "Dry run of what images get built and order they would get built in");
            IsDryRun = isDryRun;

            string manifest = "manifest.json";

            syntax.DefineOption("manifest", ref manifest, "Path to json file which describes the repo");
            Manifest = manifest;

            string registryOverride = null;

            syntax.DefineOption("registry-override", ref registryOverride, "Alternative registry which overrides the manifest");
            RegistryOverride = registryOverride;

            string repo = null;

            syntax.DefineOption("repo", ref repo, "Repo to operate on (Default is all)");
            Repo = repo;

            IReadOnlyList <string> repoOverrides = Array.Empty <string>();

            syntax.DefineOptionList("repo-override", ref repoOverrides, "Alternative repos which overrides the manifest (<target repo>=<override>)");
            RepoOverrides = repoOverrides
                            .Select(pair => pair.Split(new char[] { '=' }, 2))
                            .ToDictionary(split => split[0], split => split[1]);

            string repoPrefix = null;

            syntax.DefineOption("repo-prefix", ref repoPrefix, "Prefix to add to the repo names specified in the manifest");
            RepoPrefix = repoPrefix;

            IReadOnlyList <string> variables = Array.Empty <string>();

            syntax.DefineOptionList("var", ref variables, "Named variables to substitute into the manifest (<name>=<value>)");
            Variables = variables
                        .Select(pair => pair.Split(new char[] { '=' }, 2))
                        .ToDictionary(split => split[0], split => split[1]);

            bool isVerbose = false;

            syntax.DefineOption("verbose", ref isVerbose, "Show details about the tasks run");
            IsVerbose = isVerbose;
        }
Пример #9
0
 public ArgumentCommand Find(String[] arguments)
 {
     if (arguments.Length > 0)
     {
         foreach (CommandGroup g in this.commandGroups)
         {
             ArgumentCommand c = g.Find(arguments);
             if (c != null)
             {
                 return(c);
             }
         }
     }
     return(null);
 }
Пример #10
0
        public virtual void ParseCommandLine(ArgumentSyntax syntax)
        {
            ArgumentCommand command = syntax.DefineCommand(CommandName, this);

            command.Help = CommandHelp;

            bool isDryRun = false;

            syntax.DefineOption("dry-run", ref isDryRun, "Dry run of what images get built and order they would get built in");
            IsDryRun = isDryRun;

            string manifest = "manifest.json";

            syntax.DefineOption("manifest", ref manifest, "Path to json file which describes the repo");
            Manifest = manifest;

            string repo = null;

            syntax.DefineOption("repo", ref repo, "Repo to operate on (Default is all)");
            Repo = repo;
        }
Пример #11
0
 public ViewProducts()
 {
     // Tekenen van de catalogus
     Reload();
     // Initialisatie van alle knoppen
     AddPhoto      = new BasicCommand(SelectPhoto);
     Submit        = new BasicCommand(SubmitItem);
     DeleteCommand = new ArgumentCommand <int>(Delete);
     EditCommand   = new ArgumentCommand <int>(EditItem);
     AddCommand    = new BasicCommand(AddItem);
     CancelAdd     = new BasicCommand(CancelAddItem);
     SaveEdit      = new BasicCommand(SubmitEditedItem);
     CancelEdit    = new BasicCommand(CancelEditPopup);
     EditPhoto     = new BasicCommand(SelectPhoto);
     //Controleert of het niet in een unit test wordt gedraaid
     if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
     {
         //Dit wordt gebruikt door de snackbar om feedback te geven op
         //verwijderen, toevoegen en aanpassen van producten
         MessageQueue = new SnackbarMessageQueue();
     }
 }
Пример #12
0
        public void Run(params string[] args)
        {
            try
            {
                // Initialize
                Console.WriteLine();
                Console.WriteLine("EvolutionNet Project Generator");
                Console.WriteLine();

                // Create the command argument
                var command = new ArgumentCommand("project", "Project to be created.", CreateProject);
                // Create the options arguments
                var options = new List <ArgumentOption>();
                var basePathOptionArguments = new List <ArgumentInternal>();
                basePathOptionArguments.Add(new ArgumentInternal("path", "Absolute path."));
                var basePathOption = new ArgumentOption("basepath", "b", "Base path for project creation.", basePathOptionArguments, SetBasePathOption);
                options.Add(basePathOption);
                // Create the CommandLineHelper (for processing the arguments)
                commandLineHelper = new CommandLineHelper(command, options, ShowHelp, GetProjectName);
                commandLineHelper.Process(args);

                // Finalize
                Console.WriteLine("SUCCESS: Project(s) created!");
            }
            catch (Exception ex)
            {
                // Write errors to screen
                Console.WriteLine("ERRORS:");
                Console.WriteLine("{0}", ex.Message);
                Console.WriteLine();
            }
            finally
            {
                Console.Write("Press any key to continue");
                Console.ReadKey();
            }
        }
Пример #13
0
        private static int MainInner(string[] args)
        {
            var commandText     = string.Empty;
            var projectPath     = string.Empty;
            var versionJsonRoot = string.Empty;
            var version         = string.Empty;
            IReadOnlyList <string> cloudVariables = Array.Empty <string>();
            var    format                  = string.Empty;
            string singleVariable          = null;
            bool   quiet                   = false;
            var    cisystem                = string.Empty;
            bool   cloudBuildCommonVars    = false;
            bool   cloudBuildAllVars       = false;
            string releasePreReleaseTag    = null;
            string releaseNextVersion      = null;
            string releaseVersionIncrement = null;

            ArgumentCommand <string> install        = null;
            ArgumentCommand <string> getVersion     = null;
            ArgumentCommand <string> setVersion     = null;
            ArgumentCommand <string> tag            = null;
            ArgumentCommand <string> getCommits     = null;
            ArgumentCommand <string> cloud          = null;
            ArgumentCommand <string> prepareRelease = null;

            ArgumentSyntax.Parse(args, syntax =>
            {
                install = syntax.DefineCommand("install", ref commandText, "Prepares a project to have version stamps applied using Nerdbank.GitVersioning.");
                syntax.DefineOption("p|path", ref versionJsonRoot, "The path to the directory that should contain the version.json file. The default is the root of the git repo.");
                syntax.DefineOption("v|version", ref version, $"The initial version to set. The default is {DefaultVersionSpec}.");

                getVersion = syntax.DefineCommand("get-version", ref commandText, "Gets the version information for a project.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the current directory.");
                syntax.DefineOption("f|format", ref format, $"The format to write the version information. Allowed values are: text, json. The default is {DefaultOutputFormat}.");
                syntax.DefineOption("v|variable", ref singleVariable, "The name of just one version property to print to stdout. When specified, the output is always in raw text. Useful in scripts.");
                syntax.DefineParameter("commit-ish", ref version, $"The commit/ref to get the version information for. The default is {DefaultRef}.");

                setVersion = syntax.DefineCommand("set-version", ref commandText, "Updates the version stamp that is applied to a project.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the root directory of the repo that spans the current directory, or an existing version.json file, if applicable.");
                syntax.DefineParameter("version", ref version, "The version to set.");

                tag = syntax.DefineCommand("tag", ref commandText, "Creates a git tag to mark a version.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the root directory of the repo that spans the current directory, or an existing version.json file, if applicable.");
                syntax.DefineParameter("versionOrRef", ref version, $"The a.b.c[.d] version or git ref to be tagged. If not specified, {DefaultRef} is used.");

                getCommits = syntax.DefineCommand("get-commits", ref commandText, "Gets the commit(s) that match a given version.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the root directory of the repo that spans the current directory, or an existing version.json file, if applicable.");
                syntax.DefineOption("q|quiet", ref quiet, "Use minimal output.");
                syntax.DefineParameter("version", ref version, "The a.b.c[.d] version to find.");

                cloud = syntax.DefineCommand("cloud", ref commandText, "Communicates with the ambient cloud build to set the build number and/or other cloud build variables.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory used to calculate the version. The default is the current directory. Ignored if the -v option is specified.");
                syntax.DefineOption("v|version", ref version, "The string to use for the cloud build number. If not specified, the computed version will be used.");
                syntax.DefineOption("s|ci-system", ref cisystem, "Force activation for a particular CI system. If not specified, auto-detection will be used. Supported values are: " + string.Join(", ", CloudProviderNames));
                syntax.DefineOption("a|all-vars", ref cloudBuildAllVars, false, "Defines ALL version variables as cloud build variables, with a \"NBGV_\" prefix.");
                syntax.DefineOption("c|common-vars", ref cloudBuildCommonVars, false, "Defines a few common version variables as cloud build variables, with a \"Git\" prefix (e.g. GitBuildVersion, GitBuildVersionSimple, GitAssemblyInformationalVersion).");
                syntax.DefineOptionList("d|define", ref cloudVariables, "Additional cloud build variables to define. Each should be in the NAME=VALUE syntax.");

                prepareRelease = syntax.DefineCommand("prepare-release", ref commandText, "Prepares a release by creating a release branch for the current version and adjusting the version on the current branch.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the current directory.");
                syntax.DefineOption("nextVersion", ref releaseNextVersion, "The version to set for the current branch. If omitted, the next version is determined automatically by incrementing the current version.");
                syntax.DefineOption("versionIncrement", ref releaseVersionIncrement, "Overrides the 'versionIncrement' setting set in version.json for determining the next version of the current branch.");
                syntax.DefineOption("f|format", ref format, $"The format to write information about the release. Allowed values are: text, json. The default is {DefaultOutputFormat}.");
                syntax.DefineParameter("tag", ref releasePreReleaseTag, "The prerelease tag to apply on the release branch (if any). If not specified, any existing prerelease tag will be removed. The preceding hyphen may be omitted.");

                if (syntax.ActiveCommand == null)
                {
                    Console.WriteLine("nbgv v{0}", ThisAssembly.AssemblyInformationalVersion);
                    Console.WriteLine("Use -h, --help, or -? for usage help. Use after a command to get more help about a particular command.");
                }
            });

            if (install.IsActive)
            {
                exitCode = OnInstallCommand(versionJsonRoot, version);
            }
            else if (getVersion.IsActive)
            {
                exitCode = OnGetVersionCommand(projectPath, format, singleVariable, version);
            }
            else if (setVersion.IsActive)
            {
                exitCode = OnSetVersionCommand(projectPath, version);
            }
            else if (tag.IsActive)
            {
                exitCode = OnTagCommand(projectPath, version);
            }
            else if (getCommits.IsActive)
            {
                exitCode = OnGetCommitsCommand(projectPath, version, quiet);
            }
            else if (cloud.IsActive)
            {
                exitCode = OnCloudCommand(projectPath, version, cisystem, cloudBuildAllVars, cloudBuildCommonVars, cloudVariables);
            }
            else if (prepareRelease.IsActive)
            {
                exitCode = OnPrepareReleaseCommand(projectPath, releasePreReleaseTag, releaseNextVersion, releaseVersionIncrement, format);
            }

            return((int)exitCode);
        }
Пример #14
0
        public static int Main(string[] args)
        {
            var commandText     = string.Empty;
            var projectPath     = string.Empty;
            var versionJsonRoot = string.Empty;
            var version         = string.Empty;
            IReadOnlyList <string> cloudVariables = Array.Empty <string>();
            var  format               = string.Empty;
            bool quiet                = false;
            var  cisystem             = string.Empty;
            bool cloudBuildCommonVars = false;
            bool cloudBuildAllVars    = false;

            ArgumentCommand <string> install    = null;
            ArgumentCommand <string> getVersion = null;
            ArgumentCommand <string> setVersion = null;
            ArgumentCommand <string> tag        = null;
            ArgumentCommand <string> getCommits = null;
            ArgumentCommand <string> cloud      = null;

            ArgumentSyntax.Parse(args, syntax =>
            {
                install = syntax.DefineCommand("install", ref commandText, "Prepares a project to have version stamps applied using Nerdbank.GitVersioning.");
                syntax.DefineOption("p|path", ref versionJsonRoot, "The path to the directory that should contain the version.json file. The default is the root of the git repo.");
                syntax.DefineOption("v|version", ref version, $"The initial version to set. The default is {DefaultVersionSpec}.");

                getVersion = syntax.DefineCommand("get-version", ref commandText, "Gets the version information for a project.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the current directory.");
                syntax.DefineOption("f|format", ref format, $"The format to write the version information. Allowed values are: text, json. The default is {DefaultVersionInfoFormat}.");
                syntax.DefineParameter("commit-ish", ref version, $"The commit/ref to get the version information for. The default is {DefaultRef}.");

                setVersion = syntax.DefineCommand("set-version", ref commandText, "Updates the version stamp that is applied to a project.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the root directory of the repo that spans the current directory, or an existing version.json file, if applicable.");
                syntax.DefineParameter("version", ref version, "The version to set.");

                tag = syntax.DefineCommand("tag", ref commandText, "Creates a git tag to mark a version.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the root directory of the repo that spans the current directory, or an existing version.json file, if applicable.");
                syntax.DefineParameter("versionOrRef", ref version, $"The a.b.c[.d] version or git ref to be tagged. If not specified, {DefaultRef} is used.");

                getCommits = syntax.DefineCommand("get-commits", ref commandText, "Gets the commit(s) that match a given version.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory. The default is the root directory of the repo that spans the current directory, or an existing version.json file, if applicable.");
                syntax.DefineOption("q|quiet", ref quiet, "Use minimal output.");
                syntax.DefineParameter("version", ref version, "The a.b.c[.d] version to find.");

                cloud = syntax.DefineCommand("cloud", ref commandText, "Communicates with the ambient cloud build to set the build number and/or other cloud build variables.");
                syntax.DefineOption("p|project", ref projectPath, "The path to the project or project directory used to calculate the version. The default is the current directory. Ignored if the -v option is specified.");
                syntax.DefineOption("v|version", ref version, "The string to use for the cloud build number. If not specified, the computed version will be used.");
                syntax.DefineOption("s|ci-system", ref cisystem, "Force activation for a particular CI system. If not specified, auto-detection will be used. Supported values are: " + string.Join(", ", CloudProviderNames));
                syntax.DefineOption("a|all-vars", ref cloudBuildAllVars, false, "Defines ALL version variables as cloud build variables, with a \"NBGV_\" prefix.");
                syntax.DefineOption("c|common-vars", ref cloudBuildCommonVars, false, "Defines a few common version variables as cloud build variables, with a \"Git\" prefix (e.g. GitBuildVersion, GitBuildVersionSimple, GitAssemblyInformationalVersion).");
                syntax.DefineOptionList("d|define", ref cloudVariables, "Additional cloud build variables to define. Each should be in the NAME=VALUE syntax.");
            });

            if (install.IsActive)
            {
                exitCode = OnInstallCommand(versionJsonRoot, version);
            }
            else if (getVersion.IsActive)
            {
                exitCode = OnGetVersionCommand(projectPath, format, version);
            }
            else if (setVersion.IsActive)
            {
                exitCode = OnSetVersionCommand(projectPath, version);
            }
            else if (tag.IsActive)
            {
                exitCode = OnTagCommand(projectPath, version);
            }
            else if (getCommits.IsActive)
            {
                exitCode = OnGetCommitsCommand(projectPath, version, quiet);
            }
            else if (cloud.IsActive)
            {
                exitCode = OnCloudCommand(projectPath, version, cisystem, cloudBuildAllVars, cloudBuildCommonVars, cloudVariables);
            }

            return((int)exitCode);
        }