You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-06 09:19:22 +02:00
Minor CLI bug fixes and improvements
This commit is contained in:
@@ -39,7 +39,6 @@ class Command extends BaseCommand {
|
||||
}
|
||||
} else {
|
||||
folderTitle = filename(filePath);
|
||||
folderTitle = _('Imported - %s', folderTitle);
|
||||
let inc = 0;
|
||||
while (true) {
|
||||
let t = folderTitle + (inc ? ' (' + inc + ')' : '');
|
||||
|
||||
@@ -76,7 +76,7 @@ class Command extends BaseCommand {
|
||||
this.syncTarget_ = Setting.value('sync.target');
|
||||
if (args.options.target) this.syncTarget_ = args.options.target;
|
||||
|
||||
if (this.syncTarget_ == Setting.SYNC_TARGET_ONEDRIVE && !await reg.syncHasAuth(this.syncTarget_)) {
|
||||
if (this.syncTarget_ == Setting.SYNC_TARGET_ONEDRIVE && !reg.syncHasAuth(this.syncTarget_)) {
|
||||
const oneDriveApiUtils = new OneDriveApiNodeUtils(reg.oneDriveApi());
|
||||
const auth = await oneDriveApiUtils.oauthDance(this);
|
||||
Setting.setValue('sync.3.auth', auth ? JSON.stringify(auth) : null);
|
||||
@@ -139,7 +139,7 @@ class Command extends BaseCommand {
|
||||
vorpalUtils.redrawDone();
|
||||
this.log(_('Cancelling...'));
|
||||
|
||||
if (await reg.syncHasAuth(target)) {
|
||||
if (reg.syncHasAuth(target)) {
|
||||
let sync = await reg.synchronizer(target);
|
||||
if (sync) sync.cancel();
|
||||
} else {
|
||||
|
||||
50
CliClient/app/command-todo.js
Normal file
50
CliClient/app/command-todo.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import { BaseCommand } from './base-command.js';
|
||||
import { app } from './app.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { BaseModel } from 'lib/base-model.js';
|
||||
import { Folder } from 'lib/models/folder.js';
|
||||
import { Note } from 'lib/models/note.js';
|
||||
import { time } from 'lib/time-utils.js';
|
||||
import { autocompleteItems } from './autocomplete.js';
|
||||
|
||||
class Command extends BaseCommand {
|
||||
|
||||
usage() {
|
||||
return 'todo <action> <pattern>';
|
||||
}
|
||||
|
||||
description() {
|
||||
return _('<action> can either be "toggle" or "clear". Use "toggle" to toggle the given todo between completed and uncompleted state (If the target is not a single note it will be converted to a todo). Use "clear" to convert the todo back to a regular note.');
|
||||
}
|
||||
|
||||
autocomplete() {
|
||||
return { data: autocompleteItems };
|
||||
}
|
||||
|
||||
async action(args) {
|
||||
const action = args.action;
|
||||
const pattern = args.pattern;
|
||||
const notes = await app().loadItems(BaseModel.TYPE_NOTE, pattern);
|
||||
if (!notes.length) throw new Error(_('Cannot find "%s".', pattern));
|
||||
|
||||
for (let i = 0; i < notes.length; i++) {
|
||||
const note = notes[i];
|
||||
|
||||
let toSave = {
|
||||
id: note.id,
|
||||
};
|
||||
|
||||
if (action == 'toggle') {
|
||||
toSave.todo_completed = note.todo_completed ? 0 : time.unixMs();
|
||||
if (!note.is_todo) toSave.is_todo = 1;
|
||||
} else if (action == 'clear') {
|
||||
toSave.is_todo = 0;
|
||||
}
|
||||
|
||||
await Note.save(toSave);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Command;
|
||||
@@ -20,11 +20,25 @@ class OneDriveApiNodeUtils {
|
||||
return [1917, 9917, 8917];
|
||||
}
|
||||
|
||||
makePage(message) {
|
||||
const header = `
|
||||
<!doctype html>
|
||||
<html><head><meta charset="utf-8"></head><body>`;
|
||||
|
||||
const footer = `
|
||||
</body></html>
|
||||
`;
|
||||
|
||||
return header + message + footer;
|
||||
}
|
||||
|
||||
async oauthDance(targetConsole = null) {
|
||||
if (targetConsole === null) targetConsole = console;
|
||||
|
||||
this.api().setAuth(null);
|
||||
|
||||
|
||||
|
||||
let ports = this.possibleOAuthDancePorts();
|
||||
let port = null;
|
||||
for (let i = 0; i < ports.length; i++) {
|
||||
@@ -46,9 +60,9 @@ class OneDriveApiNodeUtils {
|
||||
server.on('request', (request, response) => {
|
||||
const query = urlParser.parse(request.url, true).query;
|
||||
|
||||
function writeResponse(code, message) {
|
||||
const writeResponse = (code, message) => {
|
||||
response.writeHead(code, {"Content-Type": "text/html"});
|
||||
response.write(message);
|
||||
response.write(this.makePage(message));
|
||||
response.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,10 +110,6 @@ msgstr ""
|
||||
msgid "Folder does not exists: \"%s\". Create it?"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "Imported - %s"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "File \"%s\" will be imported into notebook \"%s\". Continue?"
|
||||
msgstr ""
|
||||
@@ -252,6 +248,13 @@ msgstr ""
|
||||
msgid "Invalid command: \"%s\""
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"<action> can either be \"toggle\" or \"clear\". Use \"toggle\" to toggle the "
|
||||
"given todo between completed and uncompleted state (If the target is not a "
|
||||
"single note it will be converted to a todo). Use \"clear\" to convert the "
|
||||
"todo back to a regular note."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Switches to [notebook] - all further operations will happen within this "
|
||||
"notebook."
|
||||
@@ -267,10 +270,6 @@ msgstr ""
|
||||
msgid "Fatal error:"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "All potential ports are in use - please report the issue at %s"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"The application has been authorised - you may now close this browser tab."
|
||||
msgstr ""
|
||||
|
||||
@@ -121,10 +121,6 @@ msgstr "Ne pas demander de confirmation."
|
||||
msgid "Folder does not exists: \"%s\". Create it?"
|
||||
msgstr "Ce carnet n'existe pas : \"%s\". Le créer ?"
|
||||
|
||||
#, javascript-format
|
||||
msgid "Imported - %s"
|
||||
msgstr "Importé - %s"
|
||||
|
||||
#, javascript-format
|
||||
msgid "File \"%s\" will be imported into notebook \"%s\". Continue?"
|
||||
msgstr "Le fichier \"%s\" va être importé dans le carnet \"%s\". Continuer ?"
|
||||
@@ -280,6 +276,13 @@ msgstr ""
|
||||
msgid "Invalid command: \"%s\""
|
||||
msgstr "Commande invalie : \"%s\""
|
||||
|
||||
msgid ""
|
||||
"<action> can either be \"toggle\" or \"clear\". Use \"toggle\" to toggle the "
|
||||
"given todo between completed and uncompleted state (If the target is not a "
|
||||
"single note it will be converted to a todo). Use \"clear\" to convert the "
|
||||
"todo back to a regular note."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Switches to [notebook] - all further operations will happen within this "
|
||||
"notebook."
|
||||
@@ -296,12 +299,6 @@ msgstr "%s %s (%s)"
|
||||
msgid "Fatal error:"
|
||||
msgstr "Erreur fatale :"
|
||||
|
||||
#, javascript-format
|
||||
msgid "All potential ports are in use - please report the issue at %s"
|
||||
msgstr ""
|
||||
"Tous les ports sont en cours d'utilisation. Veuillez signaler ce problème "
|
||||
"sur %s"
|
||||
|
||||
msgid ""
|
||||
"The application has been authorised - you may now close this browser tab."
|
||||
msgstr "Le logiciel a été autorisé. Vous pouvez maintenant fermer cet onglet."
|
||||
@@ -556,6 +553,14 @@ msgstr ""
|
||||
msgid "Welcome"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "All potential ports are in use - please report the issue at %s"
|
||||
#~ msgstr ""
|
||||
#~ "Tous les ports sont en cours d'utilisation. Veuillez signaler ce problème "
|
||||
#~ "sur %s"
|
||||
|
||||
#~ msgid "Imported - %s"
|
||||
#~ msgstr "Importé - %s"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "There is currently no notebook. Create one by clicking on the (+) button."
|
||||
#~ msgstr ""
|
||||
|
||||
@@ -110,10 +110,6 @@ msgstr ""
|
||||
msgid "Folder does not exists: \"%s\". Create it?"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "Imported - %s"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "File \"%s\" will be imported into notebook \"%s\". Continue?"
|
||||
msgstr ""
|
||||
@@ -252,6 +248,13 @@ msgstr ""
|
||||
msgid "Invalid command: \"%s\""
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"<action> can either be \"toggle\" or \"clear\". Use \"toggle\" to toggle the "
|
||||
"given todo between completed and uncompleted state (If the target is not a "
|
||||
"single note it will be converted to a todo). Use \"clear\" to convert the "
|
||||
"todo back to a regular note."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Switches to [notebook] - all further operations will happen within this "
|
||||
"notebook."
|
||||
@@ -267,10 +270,6 @@ msgstr ""
|
||||
msgid "Fatal error:"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "All potential ports are in use - please report the issue at %s"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"The application has been authorised - you may now close this browser tab."
|
||||
msgstr ""
|
||||
|
||||
Reference in New Issue
Block a user