mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-09 22:47:35 +02:00
Cleaned up commands and enable only relevant ones in CLI mode
This commit is contained in:
parent
89d85541ef
commit
372b70270d
@ -94,6 +94,10 @@ class AppGui {
|
|||||||
return this.widget('console').innerWidth - 1;
|
return this.widget('console').innerWidth - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDummy() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
buildUi() {
|
buildUi() {
|
||||||
this.rootWidget_ = new ReduxRootWidget(this.store_);
|
this.rootWidget_ = new ReduxRootWidget(this.store_);
|
||||||
this.rootWidget_.name = 'root';
|
this.rootWidget_.name = 'root';
|
||||||
|
@ -413,6 +413,7 @@ class Application {
|
|||||||
|
|
||||||
dummyGui() {
|
dummyGui() {
|
||||||
return {
|
return {
|
||||||
|
isDummy: () => { return true; },
|
||||||
prompt: (initialText = '', promptString = '') => { return cliUtils.prompt(initialText, promptString); },
|
prompt: (initialText = '', promptString = '') => { return cliUtils.prompt(initialText, promptString); },
|
||||||
showConsole: () => {},
|
showConsole: () => {},
|
||||||
maximizeConsole: () => {},
|
maximizeConsole: () => {},
|
||||||
@ -430,8 +431,10 @@ class Application {
|
|||||||
reg.logger().info('execCommand()', argv);
|
reg.logger().info('execCommand()', argv);
|
||||||
const commandName = argv[0];
|
const commandName = argv[0];
|
||||||
this.activeCommand_ = this.findCommandByName(commandName);
|
this.activeCommand_ = this.findCommandByName(commandName);
|
||||||
|
|
||||||
let outException = null;
|
let outException = null;
|
||||||
try {
|
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);
|
const cmdArgs = cliUtils.makeCommandArgs(this.activeCommand_, argv);
|
||||||
await this.activeCommand_.action(cmdArgs);
|
await this.activeCommand_.action(cmdArgs);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -20,6 +20,14 @@ class BaseCommand {
|
|||||||
throw new Error('Action not defined');
|
throw new Error('Action not defined');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compatibleUis() {
|
||||||
|
return ['cli', 'gui'];
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsUi(ui) {
|
||||||
|
return this.compatibleUis().indexOf(ui) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
aliases() {
|
aliases() {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,10 @@ class Command extends BaseCommand {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
async action(args) {
|
async action(args) {
|
||||||
let title = args['note'];
|
let title = args['note'];
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ class Command extends BaseCommand {
|
|||||||
for (let n in commands) {
|
for (let n in commands) {
|
||||||
if (!commands.hasOwnProperty(n)) continue;
|
if (!commands.hasOwnProperty(n)) continue;
|
||||||
const command = commands[n];
|
const command = commands[n];
|
||||||
|
if (command.hidden()) continue;
|
||||||
commandNames.push(command.name());
|
commandNames.push(command.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ class Command extends BaseCommand {
|
|||||||
options() {
|
options() {
|
||||||
return [
|
return [
|
||||||
['-f, --force', _('Do not ask for confirmation.')],
|
['-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 lastProgress = '';
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
fuzzyMatching: args.options['fuzzy-matching'] === true,
|
|
||||||
onProgress: (progressState) => {
|
onProgress: (progressState) => {
|
||||||
let line = [];
|
let line = [];
|
||||||
line.push(_('Found: %d.', progressState.loaded));
|
line.push(_('Found: %d.', progressState.loaded));
|
||||||
|
@ -19,6 +19,10 @@ class Command extends BaseCommand {
|
|||||||
return _('Displays the notes in the current notebook. Use `ls /` to display the list of notebooks.');
|
return _('Displays the notes in the current notebook. Use `ls /` to display the list of notebooks.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
options() {
|
options() {
|
||||||
return [
|
return [
|
||||||
['-n, --limit <num>', _('Displays only the first top <num> notes.')],
|
['-n, --limit <num>', _('Displays only the first top <num> notes.')],
|
||||||
|
@ -13,10 +13,6 @@ class Command extends BaseCommand {
|
|||||||
return 'rmnote <note-pattern>';
|
return 'rmnote <note-pattern>';
|
||||||
}
|
}
|
||||||
|
|
||||||
aliases() {
|
|
||||||
return ['rm'];
|
|
||||||
}
|
|
||||||
|
|
||||||
description() {
|
description() {
|
||||||
return _('Deletes the notes matching <note-pattern>.');
|
return _('Deletes the notes matching <note-pattern>.');
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ class Command extends BaseCommand {
|
|||||||
return _('Searches for the given <pattern> in all the notes.');
|
return _('Searches for the given <pattern> in all the notes.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compatibleUis() {
|
||||||
|
return ['gui'];
|
||||||
|
}
|
||||||
|
|
||||||
async action(args) {
|
async action(args) {
|
||||||
let pattern = args['pattern'];
|
let pattern = args['pattern'];
|
||||||
let folderTitle = args['notebook'];
|
let folderTitle = args['notebook'];
|
||||||
|
@ -12,6 +12,10 @@ class Command extends BaseCommand {
|
|||||||
return 'set <note> <name> [value]';
|
return 'set <note> <name> [value]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
description() {
|
description() {
|
||||||
return _('Sets the property <name> of the given <note> to the given [value].');
|
return _('Sets the property <name> of the given <note> to the given [value].');
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ class Command extends BaseCommand {
|
|||||||
return { data: autocompleteFolders };
|
return { data: autocompleteFolders };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
async action(args) {
|
async action(args) {
|
||||||
let folder = await app().loadItem(BaseModel.TYPE_FOLDER, args['notebook']);
|
let folder = await app().loadItem(BaseModel.TYPE_FOLDER, args['notebook']);
|
||||||
if (!folder) throw new Error(_('Cannot find "%s".', args['notebook']));
|
if (!folder) throw new Error(_('Cannot find "%s".', args['notebook']));
|
||||||
|
@ -99,6 +99,10 @@ msgstr ""
|
|||||||
msgid "Cancelling background synchronisation... Please wait."
|
msgid "Cancelling background synchronisation... Please wait."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#, javascript-format
|
||||||
|
msgid "The command \"%s\" is only available in GUI mode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Only Bash is currently supported for autocompletion."
|
msgid "Only Bash is currently supported for autocompletion."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -254,8 +258,8 @@ msgid "To move from one widget to another, press Tab or Shift+Tab."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Use the arrows and page up/down to scroll the lists and text area (including "
|
"Use the arrows and page up/down to scroll the lists and text areas "
|
||||||
"the console)."
|
"(including this console)."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "To maximise/minimise the console, press \"C\"."
|
msgid "To maximise/minimise the console, press \"C\"."
|
||||||
|
@ -110,6 +110,10 @@ msgstr "Quitter le logiciel."
|
|||||||
msgid "Cancelling background synchronisation... Please wait."
|
msgid "Cancelling background synchronisation... Please wait."
|
||||||
msgstr "Annulation..."
|
msgstr "Annulation..."
|
||||||
|
|
||||||
|
#, javascript-format
|
||||||
|
msgid "The command \"%s\" is only available in GUI mode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Only Bash is currently supported for autocompletion."
|
msgid "Only Bash is currently supported for autocompletion."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -281,8 +285,8 @@ msgid "To move from one widget to another, press Tab or Shift+Tab."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Use the arrows and page up/down to scroll the lists and text area (including "
|
"Use the arrows and page up/down to scroll the lists and text areas "
|
||||||
"the console)."
|
"(including this console)."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
|
@ -99,6 +99,10 @@ msgstr ""
|
|||||||
msgid "Cancelling background synchronisation... Please wait."
|
msgid "Cancelling background synchronisation... Please wait."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#, javascript-format
|
||||||
|
msgid "The command \"%s\" is only available in GUI mode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Only Bash is currently supported for autocompletion."
|
msgid "Only Bash is currently supported for autocompletion."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -254,8 +258,8 @@ msgid "To move from one widget to another, press Tab or Shift+Tab."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Use the arrows and page up/down to scroll the lists and text area (including "
|
"Use the arrows and page up/down to scroll the lists and text areas "
|
||||||
"the console)."
|
"(including this console)."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "To maximise/minimise the console, press \"C\"."
|
msgid "To maximise/minimise the console, press \"C\"."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user