1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-03-20 20:55:18 +02:00

Cleaned up commands and enable only relevant ones in CLI mode

This commit is contained in:
Laurent Cozic 2017-10-24 22:37:36 +01:00
parent 89d85541ef
commit 372b70270d
14 changed files with 54 additions and 12 deletions

View File

@ -94,6 +94,10 @@ class AppGui {
return this.widget('console').innerWidth - 1;
}
isDummy() {
return false;
}
buildUi() {
this.rootWidget_ = new ReduxRootWidget(this.store_);
this.rootWidget_.name = 'root';

View File

@ -413,6 +413,7 @@ class Application {
dummyGui() {
return {
isDummy: () => { return true; },
prompt: (initialText = '', promptString = '') => { return cliUtils.prompt(initialText, promptString); },
showConsole: () => {},
maximizeConsole: () => {},
@ -430,8 +431,10 @@ class Application {
reg.logger().info('execCommand()', argv);
const commandName = argv[0];
this.activeCommand_ = this.findCommandByName(commandName);
let outException = null;
try {
if (this.gui().isDummy() && !this.activeCommand_.supportsUi('cli')) throw new Error(_('The command "%s" is only available in GUI mode', this.activeCommand_.name()));
const cmdArgs = cliUtils.makeCommandArgs(this.activeCommand_, argv);
await this.activeCommand_.action(cmdArgs);
} catch (error) {

View File

@ -20,6 +20,14 @@ class BaseCommand {
throw new Error('Action not defined');
}
compatibleUis() {
return ['cli', 'gui'];
}
supportsUi(ui) {
return this.compatibleUis().indexOf(ui) >= 0;
}
aliases() {
return [];
}

View File

@ -21,6 +21,10 @@ class Command extends BaseCommand {
];
}
enabled() {
return false;
}
async action(args) {
let title = args['note'];

View File

@ -44,6 +44,7 @@ class Command extends BaseCommand {
for (let n in commands) {
if (!commands.hasOwnProperty(n)) continue;
const command = commands[n];
if (command.hidden()) continue;
commandNames.push(command.name());
}

View File

@ -19,7 +19,6 @@ class Command extends BaseCommand {
options() {
return [
['-f, --force', _('Do not ask for confirmation.')],
['--fuzzy-matching', 'For debugging purposes. Do not use.'],
];
}
@ -38,7 +37,6 @@ class Command extends BaseCommand {
let lastProgress = '';
let options = {
fuzzyMatching: args.options['fuzzy-matching'] === true,
onProgress: (progressState) => {
let line = [];
line.push(_('Found: %d.', progressState.loaded));

View File

@ -18,6 +18,10 @@ class Command extends BaseCommand {
description() {
return _('Displays the notes in the current notebook. Use `ls /` to display the list of notebooks.');
}
enabled() {
return false;
}
options() {
return [

View File

@ -13,10 +13,6 @@ class Command extends BaseCommand {
return 'rmnote <note-pattern>';
}
aliases() {
return ['rm'];
}
description() {
return _('Deletes the notes matching <note-pattern>.');
}

View File

@ -18,6 +18,10 @@ class Command extends BaseCommand {
return _('Searches for the given <pattern> in all the notes.');
}
compatibleUis() {
return ['gui'];
}
async action(args) {
let pattern = args['pattern'];
let folderTitle = args['notebook'];

View File

@ -12,6 +12,10 @@ class Command extends BaseCommand {
return 'set <note> <name> [value]';
}
enabled() {
return false;
}
description() {
return _('Sets the property <name> of the given <note> to the given [value].');
}

View File

@ -18,6 +18,10 @@ class Command extends BaseCommand {
return { data: autocompleteFolders };
}
enabled() {
return false;
}
async action(args) {
let folder = await app().loadItem(BaseModel.TYPE_FOLDER, args['notebook']);
if (!folder) throw new Error(_('Cannot find "%s".', args['notebook']));

View File

@ -99,6 +99,10 @@ msgstr ""
msgid "Cancelling background synchronisation... Please wait."
msgstr ""
#, javascript-format
msgid "The command \"%s\" is only available in GUI mode"
msgstr ""
msgid "Only Bash is currently supported for autocompletion."
msgstr ""
@ -254,8 +258,8 @@ msgid "To move from one widget to another, press Tab or Shift+Tab."
msgstr ""
msgid ""
"Use the arrows and page up/down to scroll the lists and text area (including "
"the console)."
"Use the arrows and page up/down to scroll the lists and text areas "
"(including this console)."
msgstr ""
msgid "To maximise/minimise the console, press \"C\"."

View File

@ -110,6 +110,10 @@ msgstr "Quitter le logiciel."
msgid "Cancelling background synchronisation... Please wait."
msgstr "Annulation..."
#, javascript-format
msgid "The command \"%s\" is only available in GUI mode"
msgstr ""
msgid "Only Bash is currently supported for autocompletion."
msgstr ""
@ -281,8 +285,8 @@ msgid "To move from one widget to another, press Tab or Shift+Tab."
msgstr ""
msgid ""
"Use the arrows and page up/down to scroll the lists and text area (including "
"the console)."
"Use the arrows and page up/down to scroll the lists and text areas "
"(including this console)."
msgstr ""
#, fuzzy

View File

@ -99,6 +99,10 @@ msgstr ""
msgid "Cancelling background synchronisation... Please wait."
msgstr ""
#, javascript-format
msgid "The command \"%s\" is only available in GUI mode"
msgstr ""
msgid "Only Bash is currently supported for autocompletion."
msgstr ""
@ -254,8 +258,8 @@ msgid "To move from one widget to another, press Tab or Shift+Tab."
msgstr ""
msgid ""
"Use the arrows and page up/down to scroll the lists and text area (including "
"the console)."
"Use the arrows and page up/down to scroll the lists and text areas "
"(including this console)."
msgstr ""
msgid "To maximise/minimise the console, press \"C\"."