Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Simplify control flow by bundling two operations together #2884

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct CommandLineHandler
/** Parses the general options and sets up the log level
and the root_path
*/
void prepareOptions(CommandArgs args) {
string[] prepareOptions(CommandArgs args) {
LogLevel loglevel = LogLevel.info;

options.prepare(args);
Expand Down Expand Up @@ -200,6 +200,7 @@ struct CommandLineHandler
setLoggingColorsEnabled(false); // disable colors, no matter what
break;
}
return args.extractAllRemainingArgs();
}

/** Get an instance of the requested command.
Expand Down Expand Up @@ -461,7 +462,8 @@ int runDubCommandLine(string[] args)

auto common_args = new CommandArgs(args[1..$]);

try handler.prepareOptions(common_args);
try
args = handler.prepareOptions(common_args);
catch (Exception e) {
logError("Error processing arguments: %s", e.msg);
logDiagnostic("Full exception: %s", e.toString().sanitize);
Expand All @@ -475,8 +477,6 @@ int runDubCommandLine(string[] args)
return 0;
}

// extract the command
args = common_args.extractAllRemainingArgs();
const command_name = commandNameArgument(args);
auto command_args = new CommandArgs(args);
Command cmd;
Expand Down
Loading