Beispiel #1
0
        /// <inheritdoc/>
        public override void Run(CommandLine commandLine)
        {
            if (commandLine.Arguments.Length == 0 || commandLine.HasHelpOption)
            {
                Help();
                Program.Exit(0);
            }

            string folder = commandLine.Arguments.First();
            string path;

            switch (folder.ToLowerInvariant())
            {
            case "ansible-roles":

                path = HiveHelper.GetAnsibleRolesFolder();
                break;

            case "ansible-vault":

                path = HiveHelper.GetAnsiblePasswordsFolder();
                break;

            case "logins":

                path = HiveHelper.GetLoginFolder();
                break;

            case "setup":

                path = HiveHelper.GetVmTemplatesFolder();
                break;

            case "temp":

                path = Program.HiveTempFolder;
                break;

            case "vpn":

                path = HiveHelper.GetVpnFolder();
                break;

            default:

                Console.Error.WriteLine($"*** ERROR: Unexpected folder [{commandLine.Arguments.First()}].");
                Program.Exit(1);
                return;
            }

            if (commandLine.HasOption("--open"))
            {
                if (NeonHelper.IsWindows)
                {
                    Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe"), $"\"{path}\"");
                }
                else if (NeonHelper.IsOSX)
                {
                    throw new NotImplementedException("$todo(jeff.lill): Implement this for OSX.");
                }
                else
                {
                    throw new NotSupportedException("[--open] option is not supported on this platform.");
                }
            }
            else
            {
                Console.Write(path);
            }
        }