scsl 1.0.1
Shimmering Clarity Standard Library
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
scsl::Subcommand Class Reference

Subcommands used by Commander. More...

#include <Commander.h>

Public Types

enum class  Status : int8_t { OK = 0 , NotEnoughArgs = 1 , Failed = 2 , CommandNotRegistered = 3 }
 Status describes the results of running a Subcommand. More...
 

Public Member Functions

 Subcommand (std::string name, size_t argc, CommanderFunc func)
 
std::string Name ()
 Name returns the name of this subcommand.
 
Status Run (std::vector< std::string > args)
 

Detailed Description

Subcommands used by Commander.

Subcommands are the individual commands for the program. A Subcommand will check that it has enough arguments before running its function.

Member Enumeration Documentation

◆ Status

enum class scsl::Subcommand::Status : int8_t
strong

Status describes the results of running a Subcommand.

Enumerator
OK 

The subcommand executed correctly.

NotEnoughArgs 

Not enough arguments were supplied to the subcommand.

Failed 

The subcommand failed to run correctly.

CommandNotRegistered 

The subcommand hasn't been registered in a Commander instance.

Constructor & Destructor Documentation

◆ Subcommand()

scsl::Subcommand::Subcommand ( std::string  name,
size_t  argc,
CommanderFunc  func 
)
inline

A Subcommand is initialized with a name, the number of arguments it requires, and a function to run.

Parameters
nameThe subcommand name; this is the name that will select this command.
argcThe minimum number of arguments required by this subcommand.
funcA valid CommanderFunc.

Member Function Documentation

◆ Name()

std::string scsl::Subcommand::Name ( )
inline

Name returns the name of this subcommand.

◆ Run()

Status scsl::Subcommand::Run ( std::vector< std::string >  args)

Run attempts to run the CommanderFunc for this subcommand.

Parameters
argsThe argument list.
Returns
A Status type indicating the status of running the command.

The documentation for this class was generated from the following file: