Пример #1
0
 /// <summary>
 /// Get a list of all argument objects
 /// </summary>
 /// <returns></returns>
 public static IEnumerable <IArgument> GetAllArguments(this IArguments args)
 {
     Assert.ArgumentNotNull(args, nameof(args));
     return(args.GetAllPositionals().Cast <IArgument>()
            .Concat(args.GetAllNamed())
            .Concat(args.GetAllFlags())
            .Where(p => !p.Consumed));
 }
        public IEnumerable <IArgument> Access(IArguments args)
        {
            var results = new List <IArgument>();

            foreach (var named in args.GetAllNamed())
            {
                named.MarkConsumed();
                results.Add(new NamedArgument(named.Name, named.Value));
            }

            return(results);
        }
Пример #3
0
        public void Execute()
        {
            int index = 0;

            foreach (var p in _args.GetAllPositionals())
            {
                _output.WriteLine($"{index}: {p.Value}");
                index++;
            }

            foreach (var n in _args.GetAllNamed())
            {
                _output.WriteLine($"'{n.Name}': {n.Value}");
            }

            foreach (var f in _args.GetAllFlags())
            {
                _output.WriteLine($"flag: {f.Name}");
            }
        }