forked from Lephenixnoir/fxos
Merge pull request 'Throw error when e vspace does not exist' (#5) from Dr-Carlos/fxos:master into master
Reviewed-on: https://gitea.planet-casio.com/Lephenixnoir/fxos/pulls/5
This commit is contained in:
commit
707c154f00
21
shell/e.cpp
21
shell/e.cpp
|
@ -1,9 +1,11 @@
|
|||
#include "shell.h"
|
||||
#include "parser.h"
|
||||
#include "commands.h"
|
||||
#include "errors.h"
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <optional>
|
||||
#include <fxos/util/log.h>
|
||||
|
||||
//---
|
||||
// e
|
||||
|
@ -18,15 +20,24 @@ 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
|
||||
FxOS_log(ERR, "virtual space '%s' does not exist", args.space_name);
|
||||
|
||||
// TODO: Error message when session specified in _e does not exist
|
||||
|
||||
parser.end();
|
||||
|
|
Loading…
Reference in New Issue