Ejemplo n.º 1
0
        public CommandResult <List <string> > Alias(
            CommandEvaluationContext context,
            [Parameter(0, "name of the alias", true)] string name,
            [Parameter(1, "text of the alias", true)][OptionRequireParameter("name")] string text,
            [Option("s", "save current aliases to user aliases file")] bool save
            )
        {
            var r = new List <string>();

            if (name == null)
            {
                foreach (var kvp in context.CommandLineProcessor.CommandsAlias.Aliases)
                {
                    Out.Echoln(CommandsAlias.BuildAliasCommand(kvp.Key, kvp.Value));
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(text))
                {
                    context.CommandLineProcessor.CommandsAlias.UnsetAlias(context, name);
                }
                else
                {
                    context.CommandLineProcessor.CommandsAlias.AddOrReplaceAlias(context, name, text);
                }
            }
            if (save)
            {
                context.CommandLineProcessor.CommandsAlias.SaveAliases(context);
            }
            return(new CommandResult <List <string> >(r));
        }