载入中...
搜索中...
未找到
Get.cpp
浏览该文件的文档.
1#include "cmdline.h"
2#include "cmdline/sdk_tools.h"
3
4#include <CLI11.hpp>
5#include <rang.hpp>
6
7#include <iostream>
8
9using namespace std;
10
11namespace eve::cmd {
12
13struct GetArgs : Handler {
14 void setup(CLI::App& app, std::shared_ptr<CLI::Formatter> formatter) override {
15 auto subcmd = app.add_subcommand(
16 "get",
17 "Download and install a platform SDK matching the current eve version "
18 "(e.g. `eve get android`)");
19 subcmd->allow_extras();
20 }
21
22 int parse(CLI::App& app, Cmdline& cmd) override {
23 auto subcmd = app.get_subcommand("get");
24 if (subcmd->parsed()) {
25 string name = cmd.get_remaining(subcmd, "");
26 int res = cmd.Get(name);
27 if (res == 0) cout << rang::fg::green << "Get " << name << rang::fg::reset << endl;
28 return res;
29 }
30 return -1; // not handle
31 }
32};
33
35
36int Cmdline::Get(std::string name) {
37 using namespace sdk;
38
39 const Platform p = parsePlatform(name);
40 if (name.empty() || p == Platform::Unknown) {
41 cerr << rang::fg::red << "eve get: unknown SDK '" << name
42 << "' (supported: android)" << rang::fg::reset << endl;
43 return 2;
44 }
45 if (p != Platform::Android) {
46 cerr << rang::fg::red << "eve get: automatic SDK install is not implemented for '"
47 << platformName(p) << "' yet (supported: android)" << rang::fg::reset << endl;
48 return 2;
49 }
50 auto result = installAndroidSdk();
51 if (result.ok()) return 0;
52 cerr << rang::fg::red << "eve get: " << result.status().describe() << rang::fg::reset << endl;
53 return 3;
54}
55
56} // namespace eve::cmd
glm::vec4 p[6]
std::string name
命令行模块(eve.cmd):run / build / package / test / zip / dev-server 等子命令入口。
Definition cmdline.h:33
static std::string get_remaining(CLI::App *sub, std::string default_path=".")
子命令剩余位置参数。
Definition cmdline.cpp:80
int Get(std::string url)
获取第三方源码。
Definition Get.cpp:36
#define CMD_REG(name)
Definition cmdline.h:101
void setup(CLI::App &app, std::shared_ptr< CLI::Formatter > formatter) override
Registers options on the CLI11 sub-app.
Definition Get.cpp:14
int parse(CLI::App &app, Cmdline &cmd) override
Parses arguments and runs the command; returns the exit code.
Definition Get.cpp:22
One eve <subcommand> handler: CLI setup + argument parsing.
Definition cmdline.h:23