Skip to content

Header-only library for easily using the terminal from your C++ code

License

Notifications You must be signed in to change notification settings

AnselmoGPP/Commander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commander


Commander

This is a header-only library (see headers folder) that you can include to be able to use your terminal (command line) easily from your C++ code and for scripting from C++.

Contents:

  • headers: The single commander.h file that you can use in your project for using your terminal from your C++ code

  • example: Here you will find an example of a project that uses this library for different actions (checking current directory, moving to another directory, creating folders, copying and renaming files...). It creates a new folder called "labels" and does all his work there.

First steps:

First, you have to create an object of type commander.

#include "commander.h"
commander terminal_1;

You issue one or more orders by using the exec() function:

terminal_1.exec("cd /home/username/dev");
terminal_1.exec("mkdir new_project");

The exec function returns the output of the terminal:

std::string dir = terminal_1.exec("pwd");

Convert a string with sets of characters separated by '\n' in a set of strings:

std::string list = terminal_1.exec("ls ../some/directory");
std::vector<std::string> files;
terminal_1.extract_elements(list, files);

Links:

About

Header-only library for easily using the terminal from your C++ code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published