Skip to content
/ args Public

Simple command-line argument parser library for C++.

Notifications You must be signed in to change notification settings

viveketic/args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

args

Simple command-line argument parser library for C++.

Limitations

  • Can only handle arguments of following format
    --input=23
    --transform
  • Cannot handle arguments with same option. Example
    --input=1 --input=2

Use

  • Just include the file args.hpp.

  • For sample input arguments --input=34 --transform.

args::args args;

//argc and argv are parameters of main function
args.parse(argc,argv);

//Get value as of option as string
std::string str = args["input"].value();

//Get value of option as integer
int inputValue = args["input"].value_as<int>();

//Check argument exists or not
if(args["transform"){

}

if(args["input"){

}
  • parse() function returns bool if found any errors parsing arguments.
  • If you try to access value of argument that doesn't exist then exception will be thrown.
  • So check whether argument exist or not before accessing value or enclose the code in try-catch block.
  • Exception will be thrown if you try to acess value of flag (--transform).

About

Simple command-line argument parser library for C++.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages