-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(cli): add proper cli using args * fix: add windows specific commands for command line git interaction (#6)
- Loading branch information
Leonhard Breuer
authored
Aug 6, 2024
1 parent
aca2d28
commit 20d934b
Showing
3 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,37 @@ | ||
#include <iostream> | ||
|
||
#include <args.hxx> | ||
#include "gitutil.h" | ||
|
||
int main() { | ||
GitUtil util; | ||
std::cout << util.getVersion() << std::endl; | ||
int main(int argc, char **argv) { | ||
GitUtil gu; | ||
args::ArgumentParser parser("git utils", "© 2024 Leonhard Breuer"); | ||
args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"}); | ||
args::CompletionFlag completion(parser, {"complete"}); | ||
// commands | ||
args::Group commands(parser, "commands"); | ||
args::Command version(commands, "version", "generates the next version"); | ||
// parsing | ||
try { | ||
parser.ParseCLI(argc, argv); | ||
if (version) | ||
std::cout << gu.getVersion() << std::endl; | ||
else | ||
std::cout << "No command submitted" << std::endl; | ||
} catch(const args::Completion& e) { | ||
std::cout << e.what(); | ||
return 0; | ||
} catch(const args::Help&) { | ||
std::cout << parser << std::endl; | ||
} catch(const args::ParseError& e) { | ||
std::cerr << e.what() << std::endl; | ||
std::cerr << parser; | ||
return 1; | ||
} catch(const args::ValidationError& e) { | ||
std::cout << e.what() << std::endl; | ||
std::cout << parser.Help() << std::endl; | ||
return 1; | ||
} | ||
// GitUtil util; | ||
// std::cout << util.getVersion() << std::endl; | ||
return 0; | ||
} |