Ejemplo n.º 1
0
        private static int Execute(CommandLineApplication config, IBudgetFilesFactory budgetFilesFactory, ILog log)
        {
            var yearOption     = YearOption.Create(config);
            var monthOption    = MonthOption.Create(config);
            var currencyOption = CurrencyOption.Create(config);

            if (yearOption.NotExists || monthOption.NotExists || currencyOption.NotExists)
            {
                config.ShowHelp();
                return(ErrorCode.Value);
            }

            var(plannedBudgetFile, realBudgetFile) = budgetFilesFactory.Create(yearOption, monthOption, currencyOption);

            if (plannedBudgetFile.NotExists || realBudgetFile.NotExists)
            {
                plannedBudgetFile.Save();
                realBudgetFile.Save();

                log.Write($"Budget {plannedBudgetFile.Budget} has been created.");
                return(OkCode.Value);
            }

            log.Write($"Budget {plannedBudgetFile.Budget} already exists.");
            return(ErrorCode.Value);
        }
Ejemplo n.º 2
0
        public AddCommandBuilder(CommandLineApplication application)
        {
            _application = application;

            _yearOption        = YearOption.Create(application);
            _monthOption       = MonthOption.Create(application);
            _currencyOption    = CurrencyOption.Create(application);
            _amountOption      = AmountOption.Create(application);
            _categoryOption    = CategoryOption.Create(application);
            _descriptionOption = DescriptionOption.Create(application);
        }