载入中...
搜索中...
未找到
Doc.cpp
浏览该文件的文档.
1#include "cmdline.h"
2#include "common/config.h"
3
4#include <CLI11.hpp>
5#include <filesystem>
6#include <rang.hpp>
7
8#if defined(EVENGINE_IOS)
9#include "ios/ios.h"
10#endif
11
12using namespace std::filesystem;
13using namespace std;
14
15namespace eve::cmd {
16
17struct DocArgs : Handler {
18 void setup(CLI::App& app, std::shared_ptr<CLI::Formatter> formatter) override {
19 auto create = app.add_subcommand("doc", "Query the online documentation for a class/function");
20 create->allow_extras();
21 }
22
23 int parse(CLI::App& app, Cmdline& cmd) override {
24 auto create = app.get_subcommand("create");
25 if (create->parsed()) {
26 string name = cmd.get_remaining(create, "");
27 int res = cmd.Doc(name);
28 return res;
29 }
30 return -1; // not handle
31 }
32};
33
35
36
37// using system command to open a web page
38
39#ifdef _WIN32
40#define OPEN_WEB_PAGE_CMD "start "
41#elif defined(__APPLE__) && !defined(EVENGINE_IOS)
42#define OPEN_WEB_PAGE_CMD "open "
43#elif defined(__unix__) && !defined(EVENGINE_ANDROID)
44#define OPEN_WEB_PAGE_CMD "xdg-open "
45#endif
46
47static inline int openWebPage(string url) {
48#if defined(EVENGINE_IOS)
49 return eve::ios::openURL(url) ? 0 : -1;
50#elif defined(OPEN_WEB_PAGE_CMD)
51 string cmd = OPEN_WEB_PAGE_CMD + url;
52 return system(cmd.c_str());
53#else
54 (void)url;
55 return -1;
56#endif
57}
58
59// create a new project
60int Cmdline::Doc(std::string name) {
61 // The user/API manual lives on the organization GitHub Pages site.
62 // Doxygen has no stable per-symbol URL, so open the manual root and echo
63 // the requested symbol (useful for headless/agent invocations).
64 string url = "https://evengine.github.io/EVEngine/";
65 if (!name.empty())
66 cout << "EVEngine docs for '" << name << "': " << url << "\n";
67 else
68 cout << "EVEngine docs: " << url << "\n";
69 return openWebPage(url);
70}
71
72} // namespace eve::cmd
const char * name
Definition RockMesh.cpp:21
命令行模块(eve.cmd):run / build / package / test / zip / dev-server 等子命令入口。
Definition cmdline.h:30
int Doc(std::string name)
显示模块/函数/类型的文档。
Definition Doc.cpp:60
static std::string get_remaining(CLI::App *sub, std::string default_path=".")
子命令剩余位置参数。
Definition cmdline.cpp:79
#define CMD_REG(name)
Definition cmdline.h:92
int parse(CLI::App &app, Cmdline &cmd) override
Parses arguments and runs the command; returns the exit code.
Definition Doc.cpp:23
void setup(CLI::App &app, std::shared_ptr< CLI::Formatter > formatter) override
Registers options on the CLI11 sub-app.
Definition Doc.cpp:18
One eve <subcommand> handler: CLI setup + argument parsing.
Definition cmdline.h:21