Пример #1
0
        public static string ToYaml(this ShellCollection shells)
        {
            var serializer = new SerializerBuilder().Build();
            var yaml       = serializer.Serialize(shells);

            return(yaml);
        }
Пример #2
0
        public static ShellCollection ToShellCollection(this IEnumerable <KeyValuePair <string, string> > collection)
        {
            var shells = new ShellCollection();

            foreach (var item in collection)
            {
                shells.AddShell(item);
            }
            return(shells);
        }
Пример #3
0
        public override int Execute(CommandContext context, MenuSettings settings)
        {
            int             id     = 0;
            ShellCollection shells = settings.EnableDiscovery ? DiscoveryService.FindShells() : ConfigService.ReadConfig() ?? new ShellCollection();

            settings.ExtraShell.ToList().ForEach(s => shells.AddShell(s));
            if (shells.Count < 1)
            {
                System.Console.WriteLine("No shells available! Configure your shells, use --auto, or provide a shell with --shell to continue.");
                System.Console.ReadLine();
                return(424);
            }
            var menu = Question.Menu("Choose Shell...");

            foreach (
                KeyValuePair <string, string> shell in shells
                .ToList()
                .OrderBy(s => {
                var shell = System.Environment.GetEnvironmentVariable("SHELL");
                return(string.IsNullOrWhiteSpace(shell) ? true : s.Value != shell);
            })
                )
            {
                menu.AddOption(settings.IncludePath ? $"{shell.Key} [{shell.Value}]" : shell.Key, () => id = ShellService.SpawnShell(shell.Value));
            }
            if (settings.LoopShells)
            {
                menu.AddOption("-Exit", () => id = -1);
            }
            while (id != -1)
            {
                menu.Prompt();
                if (!settings.LoopShells)
                {
                    id = -1;
                }
            }
            return(id);
        }