2017-11-03 02:09:34 +02:00
|
|
|
const { BaseCommand } = require('./base-command.js');
|
|
|
|
const { app } = require('./app.js');
|
|
|
|
const { _ } = require('lib/locale.js');
|
2017-12-14 20:12:14 +02:00
|
|
|
const BaseModel = require('lib/BaseModel.js');
|
|
|
|
const Note = require('lib/models/Note.js');
|
2017-07-18 21:27:10 +02:00
|
|
|
|
|
|
|
class Command extends BaseCommand {
|
|
|
|
usage() {
|
2017-08-04 18:02:43 +02:00
|
|
|
return 'geoloc <note>';
|
2017-07-18 21:27:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
description() {
|
|
|
|
return _('Displays a geolocation URL for the note.');
|
|
|
|
}
|
|
|
|
|
|
|
|
async action(args) {
|
2017-08-04 18:02:43 +02:00
|
|
|
let title = args['note'];
|
2017-07-18 21:27:10 +02:00
|
|
|
|
|
|
|
let item = await app().loadItem(BaseModel.TYPE_NOTE, title, { parent: app().currentFolder() });
|
|
|
|
if (!item) throw new Error(_('Cannot find "%s".', title));
|
|
|
|
const url = Note.geolocationUrl(item);
|
2017-10-07 18:30:27 +02:00
|
|
|
this.stdout(url);
|
2017-10-25 19:23:45 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
app()
|
|
|
|
.gui()
|
|
|
|
.showConsole();
|
2017-07-18 21:27:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
module.exports = Command;
|