glance-cli 0.15.0 → 0.16.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/CHANGELOG.md +25 -10
- package/README.md +122 -172
- package/dist/cli.js +151 -136
- package/package.json +2 -2
- package/src/cli/commands.ts +679 -74
- package/src/cli/config.ts +1 -1
- package/src/cli/index.ts +29 -2
- package/src/cli/utils.ts +3 -2
package/src/cli/config.ts
CHANGED
package/src/cli/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
7
|
import chalk from "chalk";
|
|
8
8
|
import {
|
|
9
|
+
browseCommand,
|
|
9
10
|
checkServicesCommand,
|
|
10
11
|
type GlanceOptions,
|
|
11
12
|
glance,
|
|
@@ -13,13 +14,11 @@ import {
|
|
|
13
14
|
listVoicesCommand,
|
|
14
15
|
} from "./commands";
|
|
15
16
|
import { formatErrorMessage, showHelp, showVersion } from "./display";
|
|
16
|
-
// Import modules
|
|
17
17
|
import { GlanceError } from "./errors";
|
|
18
18
|
import { logger } from "./logger";
|
|
19
19
|
import { validateLanguage, validateMaxTokens, validateURL } from "./validators";
|
|
20
20
|
|
|
21
21
|
export * from "./commands";
|
|
22
|
-
// Export all modules for programmatic use
|
|
23
22
|
export * from "./config";
|
|
24
23
|
export * from "./display";
|
|
25
24
|
export * from "./errors";
|
|
@@ -78,6 +77,7 @@ function parseCliArgs() {
|
|
|
78
77
|
screenshot: { type: "string" },
|
|
79
78
|
metadata: { type: "boolean" },
|
|
80
79
|
links: { type: "boolean" },
|
|
80
|
+
browse: { type: "boolean" },
|
|
81
81
|
debug: { type: "boolean" },
|
|
82
82
|
},
|
|
83
83
|
});
|
|
@@ -127,6 +127,32 @@ export async function runCli() {
|
|
|
127
127
|
process.exit(0);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// Handle browse mode
|
|
131
|
+
if (values.browse) {
|
|
132
|
+
// Validate URL is provided for browse mode
|
|
133
|
+
if (positionals.length === 0) {
|
|
134
|
+
console.error(chalk.red("Error: No URL provided for browse mode"));
|
|
135
|
+
console.log(chalk.dim("Usage: glance <url> --browse"));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const url = positionals[0];
|
|
140
|
+
if (!url) {
|
|
141
|
+
console.error(chalk.red("Error: URL is required for browse mode."));
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Validate URL format
|
|
146
|
+
const urlValidation = validateURL(url);
|
|
147
|
+
if (!urlValidation.valid) {
|
|
148
|
+
console.error(chalk.red(`Error: ${urlValidation.error}`));
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
await browseCommand(url);
|
|
153
|
+
process.exit(0);
|
|
154
|
+
}
|
|
155
|
+
|
|
130
156
|
// Validate URL is provided
|
|
131
157
|
if (positionals.length === 0) {
|
|
132
158
|
console.error(chalk.red("Error: No URL provided"));
|
|
@@ -194,6 +220,7 @@ export async function runCli() {
|
|
|
194
220
|
preferQuality: values["prefer-quality"],
|
|
195
221
|
debug: values.debug,
|
|
196
222
|
copy: values.copy,
|
|
223
|
+
browse: values.browse,
|
|
197
224
|
};
|
|
198
225
|
|
|
199
226
|
// Run the main command
|
package/src/cli/utils.ts
CHANGED
|
@@ -130,11 +130,12 @@ export async function withRetry<T>(
|
|
|
130
130
|
/**
|
|
131
131
|
* Create a spinner with consistent styling
|
|
132
132
|
*/
|
|
133
|
-
export function createSpinner(text: string): Ora {
|
|
133
|
+
export function createSpinner(text: string, disableStdin = false): Ora {
|
|
134
134
|
return ora({
|
|
135
135
|
text,
|
|
136
136
|
spinner: "dots",
|
|
137
137
|
color: "cyan",
|
|
138
|
+
discardStdin: !disableStdin,
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
141
|
|
|
@@ -190,7 +191,7 @@ export function getTerminalWidth(): number {
|
|
|
190
191
|
* Truncate text to fit terminal width
|
|
191
192
|
*/
|
|
192
193
|
export function truncateToWidth(text: string, maxWidth?: number): string {
|
|
193
|
-
const width = maxWidth || getTerminalWidth() - 4;
|
|
194
|
+
const width = maxWidth || getTerminalWidth() - 4;
|
|
194
195
|
|
|
195
196
|
if (text.length <= width) {
|
|
196
197
|
return text;
|