feat(git): Add a --debug option, which sets the DEBUG global

I ended up removing the debugging code that used this, but it seems
useful anyway for future debug logs.
This commit is contained in:
Sam Atkins 2024-06-26 12:07:17 +01:00 committed by Eric Dubé
parent 2e4259d267
commit fa3df72f6e
2 changed files with 12 additions and 2 deletions

View File

@ -34,6 +34,11 @@ export default {
description: 'Display version information about git.',
type: 'boolean',
},
debug: {
description: 'Enable debug logging to the browser console.',
type: 'boolean',
default: false,
},
},
},
};

View File

@ -27,6 +27,7 @@ import { produce_usage_string, SHOW_USAGE } from './help.js';
const encoder = new TextEncoder();
window.Buffer = Buffer;
window.DEBUG = false;
window.main = async () => {
const shell = puter.ui.parentApp();
@ -89,6 +90,9 @@ window.main = async () => {
subcommand_name = 'version';
}
if (global_options.debug)
window.DEBUG = true;
if (!subcommand_name) {
subcommand_name = global_positionals[0];
first_positional_is_subcommand = true;
@ -111,8 +115,9 @@ window.main = async () => {
subcommand_args.splice(index, 1);
}
remove_arg('--help');
remove_arg('--version');
for (const option_name of Object.keys(git_command.args.options)) {
remove_arg(`--${option_name}`);
}
if (first_positional_is_subcommand) {
// TODO: This is not a 100% reliable way to do this, as it may also match the value of `--option-with-value value`
// But that's not a problem until we add some global options that take a value.