Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
HelpCommand.h 3.89 KiB
#ifndef _CLI_HELP_COMMAND_H_
#define _CLI_HELP_COMMAND_H_

#include <command/Command.h>
#include <environment/Environment.h>

namespace cli {

class HelpCommand : public Command {
	std::string m_command;

public:
	HelpCommand ( std::string command ) : m_command ( std::move ( command ) ) {
	}

	virtual Command::Result run ( Environment & ) const override {
		if ( m_command == "execute" ) {
			std::cout << "Execute command executes statements and either prints the result or writes the result to a file" << std::endl;
			std::cout << "statement_list:" << std::endl;
			std::cout << "statement ( | statement )* - at least one statement followed by a pipe separated sequence of other statements" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "param:" << std::endl;
			std::cout << "-                   - a value from the previous result (PreviousResultParam)" << std::endl;
			std::cout << "<( statement_list ) - a statement list serving as a param (StatementParam)" << std::endl;
			std::cout << "( type ) param      - a casted parameter (CastParam)" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "identifier   - an immediate string param - the value is a std::string (ImmediateValueParam)" << std::endl;
			std::cout << "number       - an immediate number param - the value is an int (ImmediateValueParam)" << std::endl;
			std::cout << ":identifier  - an immediate value from an environment - the value is a std::string (BindedValueParam)" << std::endl;
			std::cout << "$identifier  - a value from a variable (VariableValueParam)" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "<identifier  - a value from a xml file named (ImmediateFileParam)" << std::endl;
			std::cout << "<:identifier - a value from a xml file with a name from an environment (BindedFileParam)" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "statement:" << std::endl;
			std::cout << "name ( param )* output_spec - a statement with params (SingleStatement)" << std::endl;
			std::cout << "( type ) statement          - the result of a statement is casted (CastedStatement)" << std::endl;
			std::cout << "" << std::endl;
			std::cout << ":identifier  - an immediate value from an environment (BindedValueStatement)" << std::endl;
			std::cout << "$identifier  - a value from a variable (VariableValueStatement)" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "<identifier  - a value from a xml file (ImmediateFileStatement)" << std::endl;
			std::cout << "<:identifier - a value from a xml file with a name from an environment (BindedFileStatement)" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "output_spec:" << std::endl;
			std::cout << ">identifier  - a value to a xml file (ResultImmediateFileStatement)" << std::endl;
			std::cout << ">:identifier - a value to a xml file with name from environment (ResultBindedFileStatement)" << std::endl;
			std::cout << ">$identifier - a value to a variable (ResultVariableStatement)" << std::endl;
			std::cout << ">            - a value is discarded" << std::endl;
			std::cout << "             - an empty output specifier prints the result to the stdout (ResultPrintStatement)" << std::endl;
		} else if ( m_command == "" ) {
			std::cout << "Simple help for the query language" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "command quit: quits the processor." << std::endl;
			std::cout << "command help: shows this help." << std::endl;
			std::cout << "command introspect: prints available algorithms and algorithm overloads." << std::endl;
			std::cout << "command execute: executes statements" << std::endl;
			std::cout << "" << std::endl;
			std::cout << "for details use help of individual command" << std::endl;
		} else {
			std::cout << "The command " << m_command << " either does not exist or does not have a help entry." << std::endl;
		}
		return Command::Result::OK;
	}
};

} /* namespace cli */

#endif /* _CLI_HELP_COMMAND_H_ */