@profullstack/nichedb 0.61.1 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +18 -3
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { homedir, tmpdir } from 'node:os';
|
|
|
15
15
|
import { join } from 'node:path';
|
|
16
16
|
import { createInterface } from 'node:readline';
|
|
17
17
|
|
|
18
|
-
export const VERSION = '0.
|
|
18
|
+
export const VERSION = '0.63.0';
|
|
19
19
|
const GEO_FLAGS = ['lat', 'long', 'radius', 'unit', 'bbox', 'sort', 'offset'];
|
|
20
20
|
const DEFAULT_API = process.env.NICHEDB_API ?? 'https://nichedb.dev';
|
|
21
21
|
const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'nichedb');
|
|
@@ -252,6 +252,13 @@ export const COMMANDS = [
|
|
|
252
252
|
'A satellite, rocket stage or piece of debris: GCAT catalogue entry and where it is over the Earth right now.',
|
|
253
253
|
options: ['--json'],
|
|
254
254
|
},
|
|
255
|
+
{
|
|
256
|
+
name: 'train',
|
|
257
|
+
usage: 'train <number | station | words> [--json]',
|
|
258
|
+
summary:
|
|
259
|
+
'A train run (Amtrak, VIA Rail, Finland): where it is, its next stop and how late; or a European station.',
|
|
260
|
+
options: ['--json'],
|
|
261
|
+
},
|
|
255
262
|
{
|
|
256
263
|
name: 'ship',
|
|
257
264
|
usage: 'ship <MMSI | IMO | name> [--json]',
|
|
@@ -1200,10 +1207,16 @@ export async function run(
|
|
|
1200
1207
|
}
|
|
1201
1208
|
case 'airplane':
|
|
1202
1209
|
case 'satellite':
|
|
1203
|
-
case 'ship':
|
|
1210
|
+
case 'ship':
|
|
1211
|
+
case 'train': {
|
|
1204
1212
|
const term = rest.join(' ').trim();
|
|
1205
1213
|
if (!term) throw new Error(`${cmd} <id or name>`);
|
|
1206
|
-
const path = {
|
|
1214
|
+
const path = {
|
|
1215
|
+
airplane: 'airplanes',
|
|
1216
|
+
satellite: 'satellites',
|
|
1217
|
+
ship: 'ships',
|
|
1218
|
+
train: 'trains',
|
|
1219
|
+
}[cmd];
|
|
1207
1220
|
const r = await client.get(`/api/v1/${path}/${encodeURIComponent(term)}`);
|
|
1208
1221
|
if (json) {
|
|
1209
1222
|
out(JSON.stringify(r, null, 2));
|
|
@@ -1215,6 +1228,8 @@ export async function run(
|
|
|
1215
1228
|
return 0;
|
|
1216
1229
|
}
|
|
1217
1230
|
if (r.record) out(r.record.summary);
|
|
1231
|
+
if (cmd === 'train' && r.live?.delay)
|
|
1232
|
+
out(`now: ${r.live.delay}${r.live.nextStop ? `, next ${r.live.nextStop.name}` : ''}`);
|
|
1218
1233
|
const now = r.position ?? r.live?.[0] ?? (Array.isArray(r.live) ? null : r.live);
|
|
1219
1234
|
if (now?.lat !== undefined && now?.lat !== null) {
|
|
1220
1235
|
const extra = [
|