mirror of
https://github.com/GMGNAI/gmgn-skills.git
synced 2026-08-17 01:58:07 +00:00
fix(trenches): treat bare duration numbers as minutes with warning, update skill docs
- parseDuration: bare numbers now default to minutes (e.g. "5" → "5m") instead of hard error - Print a warning to stderr so users know the implicit conversion is happening - Update SKILL.md: document unit suffix recommendation and bare-number fallback behavior Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
981600f170
commit
cc1cb48db9
@@ -4,12 +4,18 @@ import { getConfig } from "../config.js";
|
||||
import { exitOnError, printResult } from "../output.js";
|
||||
import { validateAddress, validateChain } from "../validate.js";
|
||||
|
||||
// Parse token age string — must include a unit suffix: s (seconds) or m (minutes).
|
||||
// e.g. "30s" → "30s", "0.5m" → "0.5m". Bare numbers without a unit are rejected.
|
||||
// Parse token age string. If a unit suffix is present (s/m), use it as-is.
|
||||
// Bare numbers (no unit) are treated as minutes with a warning.
|
||||
function parseDuration(value: string): string {
|
||||
if (/^\d+(\.\d+)?[sm]$/.test(value)) return value;
|
||||
if (/^\d+(\.\d+)?$/.test(value)) {
|
||||
console.warn(
|
||||
`[gmgn-cli] Warning: no unit specified for duration "${value}" — treating as minutes (${value}m). Use a suffix to be explicit: ${value}s for seconds or ${value}m for minutes.`
|
||||
);
|
||||
return `${value}m`;
|
||||
}
|
||||
console.error(
|
||||
`[gmgn-cli] Invalid duration "${value}". A unit is required — use seconds (e.g. 30s) or minutes (e.g. 0.5m / 1m / 5m).`
|
||||
`[gmgn-cli] Invalid duration "${value}". Use seconds (e.g. 30s) or minutes (e.g. 0.5m / 1m / 5m).`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user