mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
Shell: Add a '--posix' mode to the 'dump' builtin
This commit is contained in:
parent
4efc632e15
commit
a5e4bc4faf
1 changed files with 10 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "AST.h"
|
#include "AST.h"
|
||||||
#include "Formatter.h"
|
#include "Formatter.h"
|
||||||
|
#include "PosixParser.h"
|
||||||
#include "Shell.h"
|
#include "Shell.h"
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/DeprecatedString.h>
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
|
@ -32,10 +33,17 @@ int Shell::builtin_noop(int, char const**)
|
||||||
|
|
||||||
int Shell::builtin_dump(int argc, char const** argv)
|
int Shell::builtin_dump(int argc, char const** argv)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
bool posix = false;
|
||||||
|
StringView source;
|
||||||
|
|
||||||
|
Core::ArgsParser parser;
|
||||||
|
parser.add_positional_argument(source, "Shell code to parse and dump", "source");
|
||||||
|
parser.add_option(posix, "Use the POSIX parser", "posix", 'p');
|
||||||
|
|
||||||
|
if (!parser.parse(argc, const_cast<char**>(argv), Core::ArgsParser::FailureBehavior::PrintUsage))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
Parser { StringView { argv[1], strlen(argv[1]) } }.parse()->dump(0);
|
(posix ? Posix::Parser { source }.parse() : Parser { source }.parse())->dump(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue