mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Handle command line args
This commit is contained in:
parent
2c713cdf7a
commit
01fc71d732
@ -42,19 +42,20 @@ let logger = new Logger();
|
||||
let dbLogger = new Logger();
|
||||
let syncLogger = new Logger();
|
||||
|
||||
commands.push({
|
||||
usage: 'root',
|
||||
options: [
|
||||
['--profile <filePath>', 'Sets the profile path directory.'],
|
||||
],
|
||||
action: function(args, end) {
|
||||
if (args.profile) {
|
||||
initArgs.profileDir = args.profile;
|
||||
}
|
||||
// commands.push({
|
||||
// usage: 'root',
|
||||
// options: [
|
||||
// ['--profile <filePath>', 'Sets the profile path directory.'],
|
||||
// ],
|
||||
// action: function(args, end) {
|
||||
// if (args.profile) {
|
||||
// initArgs.profileDir = args.profile;
|
||||
// args.splice(0, 2);
|
||||
// }
|
||||
|
||||
end();
|
||||
},
|
||||
});
|
||||
// end(args);
|
||||
// },
|
||||
// });
|
||||
|
||||
commands.push({
|
||||
usage: 'version',
|
||||
@ -583,14 +584,48 @@ function cmdPromptConfirm(commandInstance, message) {
|
||||
// route them to the "root" command.
|
||||
function handleStartArgs(argv) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (argv && argv.length >= 3 && argv[2][0] == '-') {
|
||||
const startParams = vorpal.parse(argv, { use: 'minimist' });
|
||||
const cmd = commandByName('root');
|
||||
cmd.action(startParams, () => { resolve(); });
|
||||
} else {
|
||||
// TODO
|
||||
resolve();
|
||||
while (true) {
|
||||
argv.splice(0, 2);
|
||||
|
||||
if (argv[0] == '--profile') {
|
||||
argv.splice(0, 1);
|
||||
if (!argv.length) throw new Error(_('Profile path is missing'));
|
||||
initArgs.profileDir = argv[0];
|
||||
argv.splice(0, 1);
|
||||
} else if (argv[0][0] === '-') {
|
||||
throw new Error(_('Unknown flag: "%s"', argv[0]));
|
||||
}
|
||||
|
||||
if (!argv.length || argv[0][0] != '-') {
|
||||
resolve(argv);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
// if (argv && argv.length >= 3 && argv[2][0] == '-') {
|
||||
// const startParams = vorpal.parse(argv, { use: 'minimist' });
|
||||
// const cmd = commandByName('root');
|
||||
// cmd.action(startParams, (newArgs) => {
|
||||
// console.info(newArgs);
|
||||
// resolve();
|
||||
// });
|
||||
// } else {
|
||||
// console.info(argv);
|
||||
// resolve();
|
||||
// }
|
||||
|
||||
}
|
||||
// if (argv && argv.length >= 3 && argv[2][0] == '-') {
|
||||
// const startParams = vorpal.parse(argv, { use: 'minimist' });
|
||||
// const cmd = commandByName('root');
|
||||
// cmd.action(startParams, (newArgs) => {
|
||||
// console.info(newArgs);
|
||||
// resolve();
|
||||
// });
|
||||
// } else {
|
||||
// console.info(argv);
|
||||
// resolve();
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes
|
||||
bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes import-enex --fuzzy-matching /home/laurent/Downloads/desktop/afaire.enex afaire
|
@ -113,14 +113,13 @@ class Setting extends BaseModel {
|
||||
let queries = [];
|
||||
queries.push('DELETE FROM settings');
|
||||
for (let i = 0; i < this.cache_.length; i++) {
|
||||
queries.push(Database.insertQuery(this.tableName(), this.cache_[i]));
|
||||
let s = Object.assign({}, this.cache_[i]);
|
||||
delete s.public;
|
||||
queries.push(Database.insertQuery(this.tableName(), s));
|
||||
}
|
||||
|
||||
return BaseModel.db().transactionExecBatch(queries).then(() => {
|
||||
this.logger().info('Settings have been saved.');
|
||||
}).catch((error) => {
|
||||
this.logger().error('Could not save settings');
|
||||
this.logger().error(error);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user