Skip to content

andreasnonslid/CPP-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Template

To skip the annoying part, and get to the good stuff.

Gives a simple CLI interface, and a helper function to perform command line commands from within your application

For the best experience, install "just" and "Ninja".

Contains

CMakeLists

Boilerplate to add a executable target and use Google Test to set up a unit test target.

CLI class

A class which is meant to be subclassed from.

The entrypoint which should not be overridden is run(...). It will parse input args and then send them to dispatch(...). dispatch(...) will either go into REPL mode if the app is called with no arguments. Otherwise, it simply passes the command to one of three functions meant to be overridden:

  1. handle_command(...): Should handle most commands
  2. show_help(...): Show something helpful
  3. show_version(...): Show the app version

Likely, the show_version(...) function will never really need to be overridden.

CommandRunner class

Simple class that only contains two fields for configuring the shell and shell args to make it flexible, have a function for live changing of those variables and finally a run command to run the commands.

Example usage is cmdRunner.run_command("cat ~/.bashrc") > returns a std::string with that file's content.

Justfile

A command handler file, for the app "just".

Allows you to do

  1. just clean
  2. just build
  3. just rebuild
  4. just run

and you could of course always add more. Just a convenient tool.

About

A simple C++ template to quickly get a CLI and simple shell interactivity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published