1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-14 11:18:47 +02:00

UI to set config

This commit is contained in:
Laurent Cozic 2017-06-27 20:01:31 +00:00
parent c18e1ac417
commit 0e93a70556

View File

@ -32,7 +32,6 @@ const packageJson = require('./package.json');
let initArgs = {
profileDir: null,
syncTarget: null,
}
let currentFolder = null;
@ -47,17 +46,12 @@ commands.push({
usage: 'root',
options: [
['--profile <filePath>', 'Sets the profile path directory.'],
['--sync-target <target>', 'Sets the sync target.'],
],
action: function(args, end) {
if (args.profile) {
initArgs.profileDir = args.profile;
}
if (args['sync-target']) {
initArgs.syncTarget = args['sync-target'];
}
end();
},
});
@ -320,6 +314,28 @@ commands.push({
autocomplete: autocompleteFolders,
});
commands.push({
usage: 'config [name] [value]',
description: 'Gets or sets a config value. If [value] is not provided, it will show the value of [name]. If neither [name] nor [value] is provided, it will list the current configuration.',
action: function(args, end) {
try {
if (!args.name && !args.value) {
let keys = Setting.publicKeys();
for (let i = 0; i < keys.length; i++) {
this.log(keys[i] + ' = ' + Setting.value(keys[i]));
}
} else if (args.name && !args.value) {
this.log(args.name + ' = ' + Setting.value(args.name));
} else {
Setting.setValue(args.name, args.value);
}
} catch(error) {
this.log(error);
}
end();
},
});
commands.push({
usage: 'sync',
description: 'Synchronizes with remote storage.',
@ -639,8 +655,6 @@ async function main() {
BaseModel.db_ = database_;
await Setting.load();
if (initArgs.syncTarget) Setting.setValue('sync.target', initArgs.syncTarget);
let activeFolderId = Setting.value('activeFolderId');
let activeFolder = null;
if (activeFolderId) activeFolder = await Folder.load(activeFolderId);