Ejemplo n.º 1
0
        public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
        {
            var windowTitle = InArguments["<window>"].ToString();

            int x, y = 0;

            if (!int.TryParse(InArguments["<x>"].ToString(), out x))
            {
                InConsole.WriteLine("Error: invalid x coordinate");
                return;
            }
            if (!int.TryParse(InArguments["<y>"].ToString(), out y))
            {
                InConsole.WriteLine("Error: invalid y coordinate");
                return;
            }

            var window = InConsole.CurrentSystem.GetWindows().FirstOrDefault(z => z.WindowTitle == windowTitle);

            if (window == null)
            {
                InConsole.WriteLine($"Error: No window found with name {windowTitle}.");
                return;
            }

            window.Left = x;
            window.Top  = y;
        }
Ejemplo n.º 2
0
        public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
        {
            int amount = 0;

            if (!int.TryParse(InArguments["<amount>"].ToString(), out amount))
            {
                InConsole.WriteLine("That's not a valid number.");
                return;
            }

            InConsole.WriteLine($"Congrats, you now have {amount} more Codepoints. :)");
            InConsole.CurrentSystem.AddCodepoints(amount);
        }
Ejemplo n.º 3
0
        protected override async Task InternalExecute(IConsoleContext context, ConsoleCommandResult result, string commandname, string commandstring, IScope scope)
        {
            var cmd = commandstring.Trim();

            if (string.IsNullOrWhiteSpace(cmd))
            {
                cmd = "all";
            }
            var d = new ResetEventData(cmd == "all");

            foreach (var component in Container.GetComponents())
            {
                if (component.Lifestyle == Lifestyle.Singleton && null != component.Implementation)
                {
                    var type = component.Implementation.GetType();
                    var ra   = type.GetCustomAttribute <RequireResetAttribute>();
                    if (null != ra && ra.IsMatch(type, cmd))
                    {
                        if (typeof(IResetable).IsAssignableFrom(type))
                        {
                            context.WriteLine(type.Name + " : " +
                                              ((IResetable)component.Implementation).Reset(d).stringify());
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected override async Task InternalExecute(IConsoleContext context, ConsoleCommandResult result, string commandname, string commandstring, IScope scope)
        {
            var data   = ReportProvider.Search(commandstring);
            var pretty = context.Parameters.Get("pretty").ToBool();

            context.WriteLine(data.stringify(pretty: pretty));
        }
Ejemplo n.º 5
0
        public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
        {
            string program = InArguments["<program>"].ToString();

            if (!InConsole.CurrentSystem.LaunchProgram(program))
            {
                InConsole.WriteLine("Error: Program not found.");
            }
        }
Ejemplo n.º 6
0
 internal static void PrintHelp(IConsoleContext consoleContext)
 {
     consoleContext.WriteLine("vsixutil [/install] extensionPath [/rootSuffix name]");
     consoleContext.WriteLine("vsixutil /uninstall identifier [/rootSuffix name]");
     consoleContext.WriteLine("vsixutil /list [filter]");
     consoleContext.WriteLine("");
     consoleContext.WriteLine("The following filters can be used with all commands:");
     consoleContext.WriteLine("   /version 15 | 2017");
     consoleContext.WriteLine("   /product com | Community | preview");
 }
Ejemplo n.º 7
0
        public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
        {
            string window = InArguments["<window>"].ToString();

            var win = InConsole.CurrentSystem.GetWindows().FirstOrDefault(x => x.WindowTitle == window);

            if (win == null)
            {
                InConsole.WriteLine($"Error: No window named {window} found.");
                return;
            }

            if (win.Enabled == false)
            {
                win.Enabled = true;
                win.Opacity = 1;
            }
            else
            {
                win.Opacity = 0;
                win.Enabled = false;
            }
        }
Ejemplo n.º 8
0
        public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
        {
            string setting = InArguments["<setting>"].ToString();
            string value   = InArguments["<value>"].ToString();

            switch (setting)
            {
            case "username":
                InConsole.CurrentSystem.Username = value;
                break;

            case "osname":
                if (!InConsole.CurrentSystem.HasShiftoriumUpgrade("osname"))
                {
                    goto default;
                }
                InConsole.CurrentSystem.OSName = value;
                break;

            default:
                InConsole.WriteLine("Error: setting not found.");
                break;
            }
        }
Ejemplo n.º 9
0
        public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
        {
            InConsole.WriteLine("");
            InConsole.WriteLine("ShiftOS Terminal help:");
            InConsole.WriteLine("");
            InConsole.WriteLine("Tips:");
            InConsole.WriteLine("");
            foreach (var tip in InConsole.CurrentSystem.GetUsefulTips().OrderBy(x => x))
            {
                InConsole.WriteLine($" - {tip}");
            }
            InConsole.WriteLine("");
            InConsole.WriteLine("Terminal commands:");
            InConsole.WriteLine("");

            foreach (var command in InConsole.CurrentSystem.GetInstalledCommands().OrderBy(x => x.Name))
            {
                InConsole.WriteLine($" - {command.Name}: {command.HelpText}");
            }

            InConsole.WriteLine("");
            InConsole.WriteLine("Programs:");
            InConsole.WriteLine("");
            foreach (var program in InConsole.CurrentSystem.GetInstalledPrograms().OrderBy(x => x))
            {
                InConsole.WriteLine($" - {program}: {InConsole.CurrentSystem.GetProgramDescription(program)}");
            }
            InConsole.WriteLine("");
        }
Ejemplo n.º 10
0
 public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
 {
     InConsole.WriteLine(InConsole.CurrentSystem.GetTimeOfDay());
 }
Ejemplo n.º 11
0
        public static CommandLine ParseCommandLine(IConsoleContext consoleContext, params string[] args)
        {
            if (args.Length == 0)
            {
                return(CommandLine.Help);
            }

            var       toolAction    = ToolAction.Help;
            VsVersion?version       = null;
            string    product       = null;
            var       rootSuffix    = "";
            var       defaultDomain = false;
            var       arg           = "";

            int index = 0;

            while (index < args.Length)
            {
                switch (args[index].ToLower())
                {
                case "/i":
                case "/install":
                    if (index + 1 >= args.Length)
                    {
                        consoleContext.Write("/install requires an argument");
                        return(CommandLine.Help);
                    }

                    toolAction = ToolAction.Install;
                    arg        = args[index + 1];
                    index     += 2;
                    break;

                case "/u":
                case "/uninstall":
                    if (index + 1 >= args.Length)
                    {
                        consoleContext.Write("/uninstall requires an argument");
                        return(CommandLine.Help);
                    }

                    toolAction = ToolAction.Uninstall;
                    arg        = args[index + 1];
                    index     += 2;
                    break;

                case "/v":
                case "/version":
                    if (index + 1 >= args.Length)
                    {
                        consoleContext.Write("/version requires an argument");
                        return(CommandLine.Help);
                    }

                    version = VsVersionUtil.ToVsVersion(args[index + 1]);
                    index  += 2;
                    break;

                case "/p":
                case "/product":
                    if (index + 1 >= args.Length)
                    {
                        consoleContext.Write("/product requires an argument");
                        return(CommandLine.Help);
                    }

                    product = args[index + 1];
                    index  += 2;
                    break;

                case "/r":
                case "/rootsuffix":
                    if (index + 1 >= args.Length)
                    {
                        consoleContext.Write("/rootSuffix requires an argument");
                        return(CommandLine.Help);
                    }

                    rootSuffix = args[index + 1];
                    index     += 2;
                    break;

                case "/defaultdomain":
                    defaultDomain = true;
                    index++;
                    break;

                case "/l":
                case "/list":
                    toolAction = ToolAction.List;
                    if (index + 1 < args.Length)
                    {
                        arg = args[index + 1];
                    }

                    index = args.Length;
                    break;

                case "/help":
                    toolAction = ToolAction.Help;
                    index      = args.Length;
                    break;

                default:
                    arg = args[index];
                    if (!arg.StartsWith("/") && args.Length == 1)
                    {
                        // Default to Install if there's a single argument.
                        toolAction = ToolAction.Install;
                        index     += 1;
                        break;
                    }

                    consoleContext.WriteLine("{0} is not a valid argument", arg);
                    return(CommandLine.Help);
                }
            }

            return(new CommandLine(toolAction, version, product, rootSuffix, arg, defaultDomain: defaultDomain));
        }
Ejemplo n.º 12
0
 public override void Run(IConsoleContext InConsole, Dictionary <string, object> InArguments)
 {
     InConsole.WriteLine($"You have {InConsole.CurrentSystem.GetCodepoints()} Codepoints.");
 }
Ejemplo n.º 13
0
 public static void WriteLine(this IConsoleContext consoleContext, string text, params object[] args)
 {
     consoleContext.WriteLine(string.Format(text, args));
 }
Ejemplo n.º 14
0
 public static void WriteLine(this IConsoleContext consoleContext)
 {
     consoleContext.WriteLine("");
 }