MCPcopy Create free account
hub / github.com/daniele77/cli / CliSession

Method CliSession

include/cli/cli.h:879–910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877 // CliSession implementation
878
879 inline CliSession::CliSession(Cli& _cli, std::ostream& _out, std::size_t historySize) :
880 cli(_cli),
881 coutPtr(Cli::CoutPtr()),
882 current(cli.RootMenu()),
883 globalScopeMenu(std::make_unique< Menu >()),
884 out(_out),
885 history(historySize)
886 {
887 history.LoadCommands(cli.GetCommands());
888
889 coutPtr->Register(out);
890 globalScopeMenu->Insert(
891 "help",
892 [this](std::ostream&){ Help(); },
893 "This help message"
894 );
895 globalScopeMenu->Insert(
896 "exit",
897 [this](std::ostream&){ Exit(); },
898 "Quit the session"
899 );
900 globalScopeMenu->Insert(
901 "history",
902 [this](std::ostream&){ ShowHistory(); },
903 "Show the history"
904 );
905 globalScopeMenu->Insert(
906 "!", {"history entry index"},
907 [this](std::ostream&, unsigned cmdIndex){ ExecFromHistory(cmdIndex); },
908 "Exec a command by index in the history"
909 );
910 }
911
912 inline void CliSession::Feed(const std::string& cmd)
913 {

Callers

nothing calls this directly

Calls 5

RootMenuMethod · 0.80
LoadCommandsMethod · 0.80
GetCommandsMethod · 0.45
RegisterMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected