GithubHelp home page GithubHelp logo

s2's Introduction

S2

跨平台C++命令式应用程序框架,注册命令方式,支持目录层级,用户模块都写成动态库形式,比如下面的Sample和SampleChild就是两个用户的动态库

使用过程如下:

bowdar@ubuntu~/build$ ./Console -l Sample -l SampleChild
>ls
    Sample
>cs Sample
Sample>help -a
    cs    <PATR>  switch command shell path
    exit
    help  [-a]
    ls            list shells in this path
    cmd1
    cmd2
Sample>ls
    SampleChild
Sample>cs SampleChild
Sample/SampleChild>help
    cs  exit   help    ls      cmd1    cmd2
Sample/SampleChild>cmd1
    No such command "cmd1" registed !
Sample/SampleChild>

命令注册代码

class SampleShell : public BaseShell
{
public:
    typedef std::shared_ptr<SampleShell> Ptr;

    SampleShell(const std::string& prompt)
    {
        REGISTER_CMD("cmd1",     "...", Sample::cmd1);
        REGISTER_CMD("cmd2",     "...", Sample::cmd2);
    }
 
    const std::string& getModuleName() override
    {
        static const std::string moduleName("SampleModule");
        return moduleName;
    }

public:
    bool cmd1(std::string command[]);
    bool cmd2(std::string command[]);
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.