forked from Lephenixnoir/fxos
_e: throw error when vspace does not exist
This commit is contained in:
parent
a6b66f380d
commit
9b334d0ee0
21
shell/e.cpp
21
shell/e.cpp
|
@ -1,6 +1,7 @@
|
|||
#include "shell.h"
|
||||
#include "parser.h"
|
||||
#include "commands.h"
|
||||
#include "errors.h"
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <optional>
|
||||
|
@ -18,15 +19,25 @@ struct _e_args
|
|||
static _e_args parse_e(Session &session, Parser &parser)
|
||||
{
|
||||
_e_args args {};
|
||||
|
||||
parser.option("vspace",
|
||||
[&args](std::string const &value) { args.space_name = value; });
|
||||
|
||||
VirtualSpace *space = session.get_space(args.space_name);
|
||||
if(space) {
|
||||
while(!parser.at_end()) {
|
||||
parser.accept_options();
|
||||
|
||||
VirtualSpace *space;
|
||||
if (!args.space_name.empty())
|
||||
space = session.get_space(args.space_name);
|
||||
else
|
||||
space = session.current_space;
|
||||
|
||||
if (space)
|
||||
while(!parser.at_end())
|
||||
args.values.push_back(parser.expr(space));
|
||||
}
|
||||
}
|
||||
else
|
||||
throw CommandError("virtual space {} does not exist",
|
||||
args.space_name);
|
||||
|
||||
// TODO: Error message when session specified in _e does not exist
|
||||
|
||||
parser.end();
|
||||
|
|
Loading…
Reference in New Issue