-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
51 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "cmd_args.h" | ||
#include <Version.h> | ||
#include <argparse/argparse.hpp> | ||
|
||
CmdArgs parseCmdArgs(int argc, char** argv) { | ||
argparse::ArgumentParser program("yarusto", VERSION_FULL); | ||
program.add_argument("-i", "--input-path") | ||
.help("The input file(.zip) path") | ||
.default_value(std::string(".")); | ||
program.add_argument("-o", "--output-path") | ||
.help("The output file(.tar) path") | ||
.default_value(std::string("./out")); | ||
|
||
program.parse_args(argc, argv); | ||
|
||
return {.inputPath = program.get<std::string>("--input-path"), | ||
.outputPath = program.get<std::string>("--output-path")}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
struct CmdArgs { | ||
std::string inputPath; | ||
std::string outputPath; | ||
}; | ||
|
||
CmdArgs parseCmdArgs(int argc, char** argv); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <args/cmd_args.h> | ||
#include <iostream> | ||
|
||
/* | ||
Usage: yarusto [--help] [--version] [--input-path VAR] [--output-path VAR] | ||
Optional arguments: | ||
-h, --help shows help message and exits | ||
-v, --version prints version information and exits | ||
-i, --input-path The input file(.zip) path [nargs=0..1] [default: "."] | ||
-o, --output-path The output file(.tar) path [nargs=0..1] [default: "./out"] | ||
*/ | ||
|
||
int main(int argc, char** argv) { | ||
CmdArgs args; | ||
try { | ||
args = parseCmdArgs(argc, argv); | ||
} catch (const std::exception& e) { | ||
std::cerr << e.what() << std::endl; | ||
return 1; | ||
} | ||
return 0; | ||
} |