コード例 #1
0
ファイル: UsageGraph.cs プロジェクト: jmarnold/FubuOnCoffee
        public void WriteUsages()
        {
            if (!_usages.Any())
            {
                Console.WriteLine("No documentation for this command");
                return;
            }

            Console.WriteLine(" Usages for '{0}' ({1})", _commandName, _description);

            if (_usages.Count == 1)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(" " + _usages.Single().Usage);
                Console.ResetColor();
            }
            else
            {
                writeMultipleUsages();
            }

            if (Arguments.Any())
            {
                writeArguments();
            }


            if (!Flags.Any())
            {
                return;
            }

            writeFlags();
        }
コード例 #2
0
ファイル: LocalsCommand.cs プロジェクト: An575/NuGet.Client
        public override Task ExecuteCommandAsync()
        {
            if ((!Arguments.Any() || string.IsNullOrWhiteSpace(Arguments[0])) ||
                (!Clear && !List) ||
                (Clear && List))
            {
                // Using both -clear and -list command options, or neither one of them, is not supported.
                // We use MinArgs = 0 even though the first argument is required,
                // to avoid throwing a command argument validation exception and
                // immediately show usage help for this command instead.
                HelpCommand.ViewHelpForCommand(CommandAttribute.CommandName);

                return(Task.FromResult(0));
            }

            var localResourceName = GetLocalResourceName(Arguments[0]);

            if (Clear)
            {
                ClearLocalResource(localResourceName);
            }
            else if (List)
            {
                ListLocalResource(localResourceName);
            }

            return(Task.FromResult(0));
        }
コード例 #3
0
        private string GetInputFile()
        {
            IEnumerable <string> files = null;

            if (Arguments.Any())
            {
                files = Arguments;
            }
            else
            {
                files = Directory.GetFiles(Directory.GetCurrentDirectory());
            }

            var candidates = files.Where(file => _allowedExtensions.Contains(Path.GetExtension(file)))
                             .ToList();

            switch (candidates.Count)
            {
            case 1:
                return(candidates.Single());

            default:
                throw new CommandLineException(NuGetResources.PackageCommandSpecifyInputFileError);
            }
        }
コード例 #4
0
        public string RenderRequest()
        {
            var request = new StringBuilder(Name);

            if (Arguments.Any())
            {
                var argList = new List <string>();
                foreach (var argument in Arguments)
                {
                    argList.Add(argument.RenderArgument());
                }

                request.Append($" ( {argList.Join(", ")} )");
            }

            if (Fields.Any())
            {
                var fieldList = new List <string>();
                foreach (var fieldBase in Fields)
                {
                    fieldList.Add(fieldBase.RenderField());
                }

                request.Append($" {{ {fieldList.Join(" ")} }} ");
            }

            return(request.ToString());
        }
コード例 #5
0
        public override void ExecuteCommand()
        {
            var arg = (Arguments.Any() ? Arguments.First().ToUpperInvariant() : null);

            if (arg != null && arg != "LIST")
            {
                if (arg != "ADD")
                {
                    if (arg != "REMOVE")
                    {
                        if (arg != "ENABLE")
                        {
                            if (arg == "DISABLE")
                            {
                                EnableOrDisableAgent(Name, false);
                            }
                            return;
                        }
                        EnableOrDisableAgent(Name, true);
                        return;
                    }
                    RemoveAgent(Name);
                    return;
                }
            }
            else
            {
                PrintRegisteredAgents();
                return;
            }
            AddNewAgent(Name, Agent);
        }
コード例 #6
0
ファイル: TestCommand.cs プロジェクト: 3F/IeXod
        private SdkCommandSpec CreateCommandSpec(IEnumerable <string> args)
        {
            var commandSpec = CreateCommand(args);

            foreach (var kvp in _environment)
            {
                commandSpec.Environment[kvp.Key] = kvp.Value;
            }

            foreach (var envToRemove in EnvironmentToRemove)
            {
                commandSpec.EnvironmentToRemove.Add(envToRemove);
            }

            if (WorkingDirectory != null)
            {
                commandSpec.WorkingDirectory = WorkingDirectory;
            }

            if (Arguments.Any())
            {
                commandSpec.Arguments = Arguments.Concat(commandSpec.Arguments).ToList();
            }

            return(commandSpec);
        }
コード例 #7
0
        private string GetInputFile()
        {
            if (Arguments.Any())
            {
                string path      = Arguments[0];
                string extension = Path.GetExtension(path) ?? string.Empty;

                if (extension.Equals(".config", StringComparison.OrdinalIgnoreCase))
                {
                    return(GetPackagesConfigPath(path));
                }

                if (extension.Equals(".sln", StringComparison.OrdinalIgnoreCase))
                {
                    return(Path.GetFullPath(path));
                }

                if (ProjectHelper.SupportedProjectExtensions.Contains(extension))
                {
                    return(Path.GetFullPath(path));
                }
            }

            return(null);
        }
コード例 #8
0
 public void Deconstruct(out string name,
                         out BrunoExpression arg0,
                         out BrunoExpression arg1)
 {
     name = Name;
     arg0 = Arguments.Any() ? Arguments.ElementAt(0) : null;
     arg1 = Arguments.Count() > 1 ? Arguments.ElementAt(1) : null;
 }
コード例 #9
0
ファイル: BotCommand.cs プロジェクト: Tetsuji-Yabuki/SmartBot
        protected override CommandActionResult ExecuteCore()
        {
            var text         = Arguments.Any() ? Arguments[0] : "";
            var httpResponse = GetResponse(text);
            var result       = GetResult(httpResponse.Result);

            return(result);
        }
コード例 #10
0
 public override bool IsCorrectArgs()
 {
     if (Arguments.Any())
     {
         throw new CommandException("Incorrect pwd command args");
     }
     return(true);
 }
コード例 #11
0
ファイル: EventAction.cs プロジェクト: RVCorp/GamesToGo
        public bool HasReferenceTo(object reference)
        {
            if (Condition.Value?.HasReferenceTo(reference) ?? false)
            {
                return(true);
            }

            return(Arguments.Any(argument => argument.Value.HasReferenceTo(reference)));
        }
コード例 #12
0
ファイル: Echo.cs プロジェクト: Rimalon/CommandShell
        public override bool IsCorrectArgs()
        {
            if (!IsFirstCommand && Arguments.Any())
            {
                throw new CommandException("Incorrect echo command args");
            }

            return(true);
        }
コード例 #13
0
        public override string ToString()
        {
            if (Arguments?.Any() ?? false)
            {
                return($"{MethodName}({Arguments.Select(x => x.Declaration).Join(", ")})");
            }

            return($"{MethodName}()");
        }
コード例 #14
0
ファイル: Argument.cs プロジェクト: RVCorp/GamesToGo
        public bool HasReferenceTo(object reference)
        {
            if (this is IHasResult resolvedArgument && resolvedArgument.ResultMapsTo(reference))
            {
                return(true);
            }

            return(Arguments.Any(subArg => subArg.Value.HasReferenceTo(reference)));
        }
コード例 #15
0
        public override string ToString()
        {
            if (Arguments.Any())
            {
                return($"Loc: {Key}: {Arguments.Select(f => f.ToString()).Aggregate((e, f) => $"{e}, {f}")}");
            }

            return("Loc:" + Key);
        }
コード例 #16
0
ファイル: Vote.cs プロジェクト: Arechii/CallVote
        protected void SendMessage(string translationKey, params object[] args)
        {
            var message = Plugin.Instance.Translate("VOTE_CHAT_FORMAT")
                          .Replace("{color}", $"<color={Settings.Color}>")
                          .Replace("{/color}", "</color>")
                          .Replace("{vote}", $"{Settings.Name}{(Arguments.Any() ? " " + string.Join(" ", Arguments) : "")}")
                          .Replace("{text}", Plugin.Instance.Translate(translationKey, args));

            ChatUtil.Broadcast(message, Settings.Icon, Color.white);
        }
コード例 #17
0
ファイル: Invoke.cs プロジェクト: meikeric/deveeldb
        /// <summary>
        /// Checks if the target of the invocation is an aggregate function.
        /// </summary>
        /// <param name="query">The query context used to resolve the routine.</param>
        /// <returns>
        /// Returns <c>true</c> if the target routine of the invocation is a <see cref="IFunction"/>
        /// and the <see cref="IFunction.FunctionType"/> is <see cref="FunctionType.Aggregate"/>,
        /// otherwise it returns <c>false</c>.
        /// </returns>
        public bool IsAggregate(IRequest query)
        {
            if (query.Query.IsAggregateFunction(this))
            {
                return(true);
            }

            // Look at parameterss
            return(Arguments.Any(x => x.HasAggregate(query)));
        }
コード例 #18
0
 private Formula CreateFormulaWithoutFunctions(Game.Game game, Dictionary <string, string> dictVariables)
 {
     if (Arguments.Any(a => a is Function))
     {
         return(new Equals(Arguments[0].CreateArgumentWithoutFunctions(game, dictVariables), Arguments[1].CreateArgumentWithoutFunctions(game, dictVariables)));
     }
     else
     {
         return(null);
     }
 }
コード例 #19
0
ファイル: BotCommand.cs プロジェクト: Tetsuji-Yabuki/SmartBot
        protected override CommandActionResult ExecuteCore()
        {
            var text   = Arguments.Any() ? Arguments[0] : "";
            var result = new CommandActionResult();

            if (text.Contains("hello"))
            {
                result.Message = "こんにちは!こんにちは!";
            }

            return(result);
        }
コード例 #20
0
        public bool HasReferenceTo(object reference)
        {
            if (Condition.Value?.HasReferenceTo(reference) ?? false)
            {
                return(true);
            }

            //Primero revisar argumentos antes de revisar tremenda lista de acciones
            return(Arguments.Any(argument => argument.Value.HasReferenceTo(reference)) ||
                   //No encontramos nada, ahora si a revisar la lista de acciones
                   Actions.Any(action => action.HasReferenceTo(reference)));
        }
コード例 #21
0
 private void Parse(string[] args)
 {
     foreach (var arg in args)
     {
         var argument = new Argument(arg);
         if (Arguments.Any(n => n.Key == argument.Key))
         {
             throw new InvalidOperationException("Duplicate argument: " + argument.Key);
         }
         Arguments.Add(argument);
     }
 }
コード例 #22
0
ファイル: Invoke.cs プロジェクト: svg-useful-backup/deveeldb
        /// <summary>
        /// Checks if the target of the invocation is an aggregate function.
        /// </summary>
        /// <param name="query">The query context used to resolve the routine.</param>
        /// <returns>
        /// Returns <c>true</c> if the target routine of the invocation is a <see cref="IFunction"/>
        /// and the <see cref="IFunction.FunctionType"/> is <see cref="FunctionType.Aggregate"/>,
        /// otherwise it returns <c>false</c>.
        /// </returns>
        public bool IsAggregate(IRequest query)
        {
            var resolvedName = query.Access().ResolveObjectName(DbObjectType.Routine, RoutineName);
            var invoke       = new Invoke(resolvedName, Arguments);

            if (query.Access().IsAggregateFunction(invoke, query))
            {
                return(true);
            }

            // Look at parameterss
            return(Arguments.Any(x => x.Value.HasAggregate(query)));
        }
コード例 #23
0
        public CallSetItemExpressionSegment(IEnumerable <IToken> memberAccessTokens, IEnumerable <Expression> arguments, ArgumentBracketPresenceOptions?zeroArgumentBracketsPresence)
        {
            if (memberAccessTokens == null)
            {
                throw new ArgumentNullException("memberAccessTokens");
            }
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }

            MemberAccessTokens = memberAccessTokens.ToList().AsReadOnly();
            if (MemberAccessTokens.Any(t => t == null))
            {
                throw new ArgumentException("Null reference encountered in memberAccessTokens set");
            }
            if (MemberAccessTokens.Any(t => t is MemberAccessorOrDecimalPointToken))
            {
                throw new ArgumentException("MemberAccessorOrDecimalPointToken tokens should not be included in the memberAccessTokens, they are implicit as token separators");
            }
            var firstUnacceptableTokenIfAny = MemberAccessTokens.FirstOrDefault(token => !AllowableTypes.Any(allowedType => allowedType.IsInstanceOfType(token)));

            if (firstUnacceptableTokenIfAny != null)
            {
                throw new ArgumentException("Unacceptable token type encountered (" + firstUnacceptableTokenIfAny.GetType() + "), only allowed types are " + string.Join <Type>(", ", AllowableTypes));
            }

            Arguments = arguments.ToList().AsReadOnly();
            if (Arguments.Any(e => e == null))
            {
                throw new ArgumentException("Null reference encountered in arguments set");
            }

            if (Arguments.Any())
            {
                if (zeroArgumentBracketsPresence != null)
                {
                    throw new ArgumentException("ZeroArgumentBracketsPresence must be null if there are arguments for this CallExpressionSegment");
                }
            }
            else if (zeroArgumentBracketsPresence == null)
            {
                throw new ArgumentException("ZeroArgumentBracketsPresence must not be null if there are zero arguments for this CallExpressionSegment");
            }
            else if (!Enum.IsDefined(typeof(ArgumentBracketPresenceOptions), zeroArgumentBracketsPresence.Value))
            {
                throw new ArgumentOutOfRangeException("zeroArgumentBracketsPresence");
            }

            ZeroArgumentBracketsPresence = zeroArgumentBracketsPresence;
        }
コード例 #24
0
ファイル: PluginCommand.cs プロジェクト: Someone999/Sync
        public bool Plugins(Arguments arg)
        {
            if (arg.Count == 0)
            {
                return(Help());
            }
            switch (arg[0])
            {
            case "search":
                return(Search(arg[1]));

            case "update":
                if (arg.Count > 1)
                {
                    var part_plugin_name = arg[1];
                    return(Update(part_plugin_name, arg.Any(a => a == "--no_ask")));
                }
                else
                {
                    return(Update(arg.Any(a => a == "--no_ask")));
                }

            case "install":
                return(Install(arg[1]));

            case "list":
                return(List());

            case "remove":
                return(Remove(arg[1]));

            case "latest":
                return(SyncUpdateCheck(true));

            default:
                return(Help());
            }
        }
コード例 #25
0
        protected override string Serialize()
        {
            if (Arguments == null || !Arguments.Any())
            {
                return($"{Name}()");
            }

            string argumentList = string.Join(", ",
                                              Arguments
                                              .TakeWhile(a => a != null)
                                              .Select(a => a.ToString()));

            return($"{Name}({argumentList})");
        }
コード例 #26
0
ファイル: PackCommand.cs プロジェクト: TMFRook/NuGet
        private string GetInputFile()
        {
            IEnumerable <string> files;

            if (Arguments.Any())
            {
                files = Arguments;
            }
            else
            {
                files = Directory.GetFiles(Directory.GetCurrentDirectory());
            }

            return(GetInputFile(files));
        }
コード例 #27
0
        public virtual void ParseCode()
        {
            var sb = new StringBuilder();

            sb.Append("public " + OutputType.ToString() + " func(");
            if (Arguments.Any())
            {
                sb.Append(Arguments.Select(e => e.InputType.ToString() + " " + e.Name).Aggregate((e, f) => $"{e},{f}"));
            }

            sb.AppendLine();
            sb.Append("{");
            sb.Append(Code);
            sb.Append("}");
            FullCode = sb.ToString();
        }
コード例 #28
0
 public object Value()
 {
     try
     {
         return(materialize());
     }
     catch (Exception exception)
     {
         var argumentsDescription = Arguments.Any()
                                                                                    ? string.Join(", ", Arguments)
                                                                                    : " (none)";
         throw new ParseException(
                   $"An exception occurred while getting the value for option '{Option.Name}' based on argument(s): {argumentsDescription}.",
                   exception);
     }
 }
コード例 #29
0
        public IHateoasLink Build()
        {
            if (Action == null)
            {
                throw new InvalidOperationException("LinkBuilder.Action property cannot be null");
            }

            if (Method == null)
            {
                throw new InvalidOperationException("LinkBuilder.Method property cannot be null");
            }

            var result = new HateoasLink
            {
                Relation = Relation
            };

            if (IsMember)
            {
                result.IsMember = IsMember;
                result.MemberId = Arguments.ContainsKey("id")
                    ? Arguments["id"]
                    : new Argument {
                    Name = "id", Value = "no-id"
                };
            }

            if (IsTemplate)
            {
                result.Template = Arguments.Any(p => p.Value.IsTemplateArgument)
                    ? this.GetPath()
                    : this.GetPathAsTemplate();
            }
            else
            {
                result.LinkPath = this.GetPath();
            }

            result.Method = Method.ToString();

            if (Command != null)
            {
                result.Command = Command;
            }

            return(result);
        }
コード例 #30
0
        public override TreeItemData ToTreeView()
        {
            var root = new TreeItemData(Type, Started, new()
            {
                new("Source File", FilePath),
                new("Filter", FilterID),
                new("Preset", Preset),
                new("Success", Success?.ToString() ?? "Unknown")
            });

            if (SSIM.HasValue)
            {
                root.TreeItems.Add(new("SSIM", SSIM.ToPercent(2).Adorn("%")));
            }
            if (Compression.HasValue)
            {
                root.TreeItems.Add(new("Compression", Compression.ToPercent(2).Adorn("%")));
            }
            if (Percentage.HasValue)
            {
                root.TreeItems.Add(new("Percentage", Percentage.Adorn("%")));
            }
            if (Speed.HasValue)
            {
                root.TreeItems.Add(new("Speed", Speed));
            }
            if (FPS.HasValue)
            {
                root.TreeItems.Add(new("FPS", FPS));
            }
            if (Arguments != null && Arguments.Any())
            {
                var argumentsTree = new TreeItemData("Arguments")
                {
                    TreeItems = new()
                };
                for (int i = 0; i < Arguments.Count; i++)
                {
                    argumentsTree.TreeItems.Add(new($"Pass {i + 1}", Arguments[i]));
                }
                root.TreeItems.Add(argumentsTree);
            }

            return(root);
        }
    }