Skip to content

Commit 823edd2

Browse files
committed
refactor: moon simple by default, -e/--extended for rich data (v0.2.21)
1 parent 77d4e45 commit 823edd2

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thoth-cli",
3-
"version": "0.2.20",
3+
"version": "0.2.21",
44
"description": "𓅝 Astrological calculations from the command line. Swiss Ephemeris precision. Built for humans and agents.",
55
"author": "AKLO <aklo@aklolabs.com>",
66
"license": "MIT",

packages/cli/src/bin.ts

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import chalk from 'chalk';
99
import ora from 'ora';
1010
import { writeFileSync } from 'fs';
1111
import {
12-
chart, transit, ephemeris, version,
12+
chart, transit, moon, ephemeris, version,
1313
solarReturn, lunarReturn, synastry, progressions, ephemerisRange,
1414
composite, solarArc, horary, score, moonExtended, transitScan, ephemerisMulti
1515
} from './lib/core.js';
1616
import {
17-
formatChart, formatTransits, formatEphemeris,
17+
formatChart, formatTransits, formatMoon, formatEphemeris,
1818
formatSolarReturn, formatLunarReturn, formatSynastry,
1919
formatProgressions, formatEphemerisRange,
2020
formatComposite, formatSolarArc, formatHorary,
@@ -81,7 +81,7 @@ EPHEMERIS & MOON
8181
REFERENCE
8282
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
8383
thoth key # full symbol reference`)
84-
.version('0.2.20');
84+
.version('0.2.21');
8585

8686
// Chart command
8787
program
@@ -624,25 +624,45 @@ program
624624
// Moon command
625625
program
626626
.command('moon')
627-
.description('Get moon phase, eclipses, sunrise/sunset')
627+
.description('Get moon phase and position')
628628
.option('--date <date>', 'Date (YYYY-MM-DD, default: today)')
629629
.option('--lat <lat>', 'Latitude', parseFloat, 40.7128)
630630
.option('--lng <lng>', 'Longitude', parseFloat, -74.0060)
631-
.option('--tz <tz>', 'Timezone', 'America/New_York')
631+
.option('--tz <tz>', 'Timezone (for --extended)', 'America/New_York')
632+
.option('-e, --extended', 'Show eclipses, sunrise/sunset, upcoming phases')
632633
.option('--json', 'Output raw JSON')
633634
.action(async (options) => {
634635
let year, month, day;
635636
if (options.date) {
636637
[year, month, day] = options.date.split('-').map(Number);
637638
}
638639

639-
const spinner = ora('Getting moon data...').start();
640+
if (options.extended) {
641+
const spinner = ora('Getting moon details...').start();
642+
const result = await moonExtended({
643+
year, month, day,
644+
lat: options.lat, lng: options.lng, tz: options.tz,
645+
});
646+
spinner.stop();
647+
648+
if (isError(result)) {
649+
console.error(chalk.red(`Error: ${result.error}`));
650+
process.exit(1);
651+
}
652+
653+
if (options.json) {
654+
console.log(JSON.stringify(result, null, 2));
655+
} else {
656+
console.log(formatMoonExtended(result));
657+
}
658+
return;
659+
}
640660

641-
const result = await moonExtended({
661+
const spinner = ora('Getting moon phase...').start();
662+
const result = await moon({
642663
year, month, day,
643-
lat: options.lat, lng: options.lng, tz: options.tz,
664+
lat: options.lat, lng: options.lng,
644665
});
645-
646666
spinner.stop();
647667

648668
if (isError(result)) {
@@ -653,7 +673,7 @@ program
653673
if (options.json) {
654674
console.log(JSON.stringify(result, null, 2));
655675
} else {
656-
console.log(formatMoonExtended(result));
676+
console.log(formatMoon(result));
657677
}
658678
});
659679

@@ -1022,7 +1042,7 @@ program
10221042

10231043
// Banner
10241044
console.log(chalk.dim(''));
1025-
console.log(chalk.yellow(' 𓅝') + chalk.dim(' thoth-cli v0.2.20'));
1045+
console.log(chalk.yellow(' 𓅝') + chalk.dim(' thoth-cli v0.2.21'));
10261046
console.log(chalk.dim(''));
10271047

10281048
program.parse();

0 commit comments

Comments
 (0)