1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/packages/app-cli/app/command-geoloc.js

31 lines
757 B
JavaScript
Raw Normal View History

const { BaseCommand } = require('./base-command.js');
const { app } = require('./app.js');
2020-11-05 18:58:23 +02:00
const { _ } = require('@joplinapp/lib/locale');
const BaseModel = require('@joplinapp/lib/BaseModel').default;
const Note = require('@joplinapp/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) {
const title = args['note'];
2017-07-18 21:27:10 +02:00
const item = await app().loadItem(BaseModel.TYPE_NOTE, title, { parent: app().currentFolder() });
2017-07-18 21:27:10 +02:00
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);
app()
.gui()
.showConsole();
2017-07-18 21:27:10 +02:00
}
}
module.exports = Command;