コード例 #1
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        public static void Main(string[] args)
        {
            IEnumerable <string> options        = null;
            NextCompletionType   completionType = NextCompletionType.None;

            switch (args[1])
            {
            case "build":
                options = GetBuildOpts(args, out completionType);
                break;

            case "new":
                options = GetNewOpts(args, out completionType);
                break;

            case "restore":
                options = GetRestoreOpts(args, out completionType);
                break;

            case "publish":
                options = GetPublishOpts(args, out completionType);
                break;

            case "run":
                options = GetRunOpts(args, out completionType);
                break;

            case "test":
                options = GetTestOpts(args, out completionType);
                break;

            case "pack":
                options = GetPackOpts(args, out completionType);
                break;

            case "help":
                options = GetHelpOpts(args, out completionType);
                break;
            }

            if (options != null)
            {
                switch (completionType)
                {
                case NextCompletionType.WordList:
                    string wordList = string.Join(" ", options);
                    Console.WriteLine($"WORDS:{wordList}");
                    break;

                case NextCompletionType.DirectoryList:
                    Console.WriteLine("DIRS:");
                    break;

                case NextCompletionType.FileList:
                    Console.WriteLine("FILES:");
                    break;
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        private static IEnumerable <string> GetNewOpts(string[] args, out NextCompletionType completionType)
        {
            CommandOption[] opts = new CommandOption[]
            {
                new CommandOption("-h", "--help"),
                new CommandOption(GetNewLangCompletions, "-l", "--lang"),
                new CommandOption(GetNewTypeCompletions, "-t", "--type"),
            };

            return(ProcessOptions(args, opts, out completionType));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        private static IEnumerable <string> GetRunOpts(string[] args, out NextCompletionType completionType)
        {
            CommandOption[] opts = new CommandOption[]
            {
                new CommandOption("-h", "--help"),
                new CommandOption(NextCompletionType.Suppress, "-f", "--framework"), //TODO: Suggest some frameworks
                new CommandOption(GetCommonBuildConfigurations, "-c", "--configuration"),
                new CommandOption(NextCompletionType.DirectoryList, "-p", "--project")
            };

            return(ProcessOptions(args, opts, out completionType));
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        private static IEnumerable <string> GetPackOpts(string[] args, out NextCompletionType completionType)
        {
            CommandOption[] opts = new CommandOption[]
            {
                new CommandOption("-h", "--help"),
                new CommandOption(NextCompletionType.DirectoryList, "-o", "--output"),
                new CommandOption("--no-build"),
                new CommandOption(NextCompletionType.DirectoryList, "-b", "--build-base-path"),
                new CommandOption(GetCommonBuildConfigurations, "-c", "--configuration"),
                new CommandOption(NextCompletionType.Suppress, "--version-suffix"),
            };

            return(ProcessOptions(args, opts, out completionType));
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        private static IEnumerable <string> GetHelpOpts(string[] args, out NextCompletionType completionType)
        {
            CommandOption[] opts = new CommandOption[]
            {
                new CommandOption(NextCompletionType.Suppress, "new"),
                new CommandOption(NextCompletionType.Suppress, "restore"),
                new CommandOption(NextCompletionType.Suppress, "build"),
                new CommandOption(NextCompletionType.Suppress, "publish"),
                new CommandOption(NextCompletionType.Suppress, "run"),
                new CommandOption(NextCompletionType.Suppress, "test"),
                new CommandOption(NextCompletionType.Suppress, "pack")
            };

            return(ProcessOptions(args, opts, out completionType));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        private static IEnumerable <string> GetPublishOpts(string[] args, out NextCompletionType completionType)
        {
            CommandOption[] opts = new CommandOption[]
            {
                new CommandOption("-h", "--help"),
                new CommandOption(NextCompletionType.Suppress, "-f", "--framework"), //TODO: Suggest some frameworks
                new CommandOption(GetCompatibleRuntimeList, "-r", "--runtime"),      //TODO: Suggest the current RID
                new CommandOption(NextCompletionType.DirectoryList, "-b", "--build-base-path"),
                new CommandOption(NextCompletionType.DirectoryList, "-o", "--output"),
                new CommandOption(NextCompletionType.Suppress, "--version-suffix"),
                new CommandOption(GetCommonBuildConfigurations, "-c", "--configuration"),
                new CommandOption("--native-subdirectory"),
                new CommandOption("--no-build")
            };

            return(ProcessOptions(args, opts, out completionType));
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        private static IEnumerable <string> GetRestoreOpts(string[] args, out NextCompletionType completionType)
        {
            CommandOption[] opts = new CommandOption[]
            {
                new CommandOption("-h", "--help"),
                new CommandOption(NextCompletionType.None, "--force-english-output"),
                new CommandOption(NextCompletionType.DirectoryList, "-s", "--source"),
                new CommandOption(NextCompletionType.DirectoryList, "--packages"),
                new CommandOption("--disable-parallel"),
                new CommandOption(NextCompletionType.DirectoryList, "-f", "--fallbacksource"),
                new CommandOption(NextCompletionType.FileList, "--configfile"),
                new CommandOption("--no-cache"),
                new CommandOption("--infer-runtimes"),
                new CommandOption(GetRestoreVerbosityOptions, "-v", "--verbosity"),
                new CommandOption("--ignore-failed-sources")
            };

            return(ProcessOptions(args, opts, out completionType));
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
        private static IEnumerable <string> ProcessOptions(string[] args, CommandOption[] opts, out NextCompletionType completionType)
        {
            List <string> allArgs = new List <string>();

            foreach (CommandOption item in opts)
            {
                if (!item.Include(args))
                {
                    IEnumerable <string> extended;
                    if (item.TryHandlePositionalArg(args, out extended))
                    {
                        completionType = item.NextType;
                        return(extended);
                    }
                }
                else
                {
                    allArgs.AddRange(item.Forms);
                }
            }

            completionType = NextCompletionType.WordList;
            return(allArgs);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: WildGenie/dotnet-bash
 public CommandOption(NextCompletionType nextType, params string[] forms)
 {
     NextType = nextType;
     Forms    = forms;
 }