Пример #1
0
        public static int Run(UpdateItemOptions opts)
        {
            var runner = new ItemRunner();
            int result = (int)ExitCodes.FailedToConvertArgs;

            try
            {
                var isNameEmpty = string.IsNullOrEmpty(opts.NewName?.Trim());
                var isTimeEmpty = !opts.Time.HasValue;

                if (opts.Replace && (isNameEmpty || isTimeEmpty))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("-r --replace switch is true");
                    Console.WriteLine("but new name (-n --newname) or time (-t --time) are empty");
                    Console.WriteLine("New name and Time are required if this is a replacement update");
                    Console.WriteLine("Ex. \"trackmat update -I a1b2c3d4e5f6a1b2c3d4e5f6 -n NEW-002 -t 3.25 -r\"");
                    Console.ResetColor();
                    throw new Exception("Replacing without a name or time");
                }

                result = runner.Update(opts.ToUpdateTrackItemArgs());
            }
            catch (Exception) { }
            return(result);
        }
Пример #2
0
        public static int Run(AddItemOptions opts)
        {
            var runner = new ItemRunner();
            int result = (int)ExitCodes.FailedToConvertArgs;

            try
            {
                result = runner.Create(opts.ToTrackItem());
            }
            catch (Exception) { }
            return(result);
        }
Пример #3
0
        public static int Run(ShowItemOptions opts)
        {
            var runner = new ItemRunner();

            return(runner.Show(opts.ToShowTrackItemArgs()));
        }
Пример #4
0
        public static int Run(DeleteItemOptions opts)
        {
            var runner = new ItemRunner();

            return(runner.Delete(opts.ToDeleteTrackItemArgs()));
        }