-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to new command line parser and add some improvements in commands
- Loading branch information
Showing
20 changed files
with
122 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
#pragma once | ||
|
||
#include <args-parser/all.hpp> | ||
#include <CLI/App.hpp> | ||
#include <memory> | ||
|
||
class BaseCommand { | ||
public: | ||
virtual ~BaseCommand() { } | ||
virtual void reg(Args::CmdLine& cmdLine) = 0; | ||
virtual bool process(const Args::CmdLine& cmdLine) = 0; | ||
virtual void reg(CLI::App& app) = 0; | ||
}; | ||
|
||
using CommandPtr = std::shared_ptr<BaseCommand>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
#include "remove_command.h" | ||
|
||
#include <stdexcept> | ||
|
||
using namespace std; | ||
|
||
RemoveCommand::RemoveCommand(const WorkspaceServicePtr& service) | ||
: service(service) | ||
{ | ||
} | ||
|
||
void RemoveCommand::reg(Args::CmdLine& cmdLine) | ||
void RemoveCommand::reg(CLI::App& app) | ||
{ | ||
cmdLine.addCommand("rm", Args::ValueOptions::OneValue, false, "Remove workspace by name", "", "", "name").end(); | ||
auto cmd | ||
= app.add_subcommand("rm", "Remove workspace")->alias("r")->callback(std::bind(&RemoveCommand::process, this)); | ||
cmd->add_option("name", name, "Name of the workspace"); | ||
} | ||
|
||
bool RemoveCommand::process(const Args::CmdLine& cmdLine) | ||
{ | ||
if (!cmdLine.isDefined("rm")) | ||
return false; | ||
auto name = cmdLine.value("rm"); | ||
if (name.empty()) | ||
throw runtime_error("Name is empty"); | ||
service->remove(name); | ||
return true; | ||
} | ||
void RemoveCommand::process() { service->remove(name); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.