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); }
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); }