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

31 lines
753 B
JavaScript
Raw Normal View History

const { BaseCommand } = require('./base-command.js');
const { app } = require('./app.js');
const { _ } = require('@joplin/lib/locale');
const BaseModel = require('@joplin/lib/BaseModel').default;
const Note = require('@joplin/lib/models/Note').default;
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;