/
thomas-king
/
ArgumentsParser
Обзор
Документация
Войти
/
thomas-king
/
ArgumentsParser
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
main.cpp
88 строк
2 KB
Ace Rodstin
Fix tests
20 ноя 2023, 21:08
20 ноя 2023, 21:08
9e5189b
Код
Авторство
О чём код?
// // main.cpp // ArgumentsParser // // Created by Ace Rodstin on 11/11/23. // Updated by Ace Rodstin on 11/20/23. // // Copyright (C) 2023 Ace Rodstin. All right reserved. // #include "ArgumentsParser/Services/ArgumentsParser.h" #include "ArgumentsParser/Models/ArgumentBundle.h" #include "Manual/Services/ManualBuilder.h" #include <iostream> #include <set> using namespace std; using namespace manual; namespace args { ArgumentBundle help { "--help", }; ArgumentBundle version { "--version" }; } void showHint() { string hint = "Run the app with \"--help\" argument to show help info for."; cout << hint << endl; } void showHelp() { Table table { Column { Cell { "Arguments" }, Cell { "--help" }, Cell { "--version" } }, Column { Cell { "Options" }, Cell { "" }, Cell { "" } }, Column { Cell { "Description" }, Cell { "Show this help info." }, Cell { "Show app version." } } }; ManualBuilder builder { table }; auto result = builder.build(); cout << result << endl; } void showAbout() { string appName = "Arguments parser"; string appVersion = "v1.0.0"; string copyright = "Copyright Ace Rodstin. All rights reserved."; cout << appName << " " << appVersion << endl; cout << copyright << endl; } int main(int argc, char** argv) { ArgumentsParser argumentsParser {}; auto arguments = argumentsParser.parse(argc, argv); while (arguments.hasMore()) { auto argument = arguments.next(); if (args::help.contains(argument)) { showHelp(); return EXIT_SUCCESS; } if (args::version.contains(argument)) { showAbout(); return EXIT_SUCCESS; } } showHint(); return EXIT_SUCCESS; }