mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
feat: Unify the text format of flag default values
This commit is contained in:
@@ -24,6 +24,10 @@ import { promptText, failIfMissing } from "../../output/prompt.ts";
|
||||
import { emitResult, emitBare } from "../../output/output.ts";
|
||||
import { resolveImageSize } from "../../utils/image-size.ts";
|
||||
import { join } from "path";
|
||||
import {
|
||||
BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE,
|
||||
BOOL_FLAG_WATERMARK,
|
||||
} from "../../utils/flag-descriptions.ts";
|
||||
|
||||
export default defineCommand({
|
||||
name: "image edit",
|
||||
@@ -51,11 +55,11 @@ export default defineCommand({
|
||||
},
|
||||
{
|
||||
flag: "--prompt-extend <bool>",
|
||||
description: "Enable prompt extend (true/false). Default: true.",
|
||||
description: BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE,
|
||||
},
|
||||
{
|
||||
flag: "--watermark <bool>",
|
||||
description: "Enable watermark (true/false). Default: true.",
|
||||
description: BOOL_FLAG_WATERMARK,
|
||||
},
|
||||
{ flag: "--out-dir <dir>", description: "Download images to directory" },
|
||||
{ flag: "--out-prefix <prefix>", description: "Filename prefix (default: edited)" },
|
||||
|
||||
@@ -26,6 +26,10 @@ import { runConcurrent, downloadParallel, getConcurrency } from "../../utils/con
|
||||
import { promptText, failIfMissing } from "../../output/prompt.ts";
|
||||
import { emitResult, emitBare } from "../../output/output.ts";
|
||||
import { resolveImageSize } from "../../utils/image-size.ts";
|
||||
import {
|
||||
BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE,
|
||||
BOOL_FLAG_WATERMARK,
|
||||
} from "../../utils/flag-descriptions.ts";
|
||||
|
||||
import { join } from "path";
|
||||
|
||||
@@ -60,12 +64,11 @@ export default defineCommand({
|
||||
},
|
||||
{
|
||||
flag: "--prompt-extend <bool>",
|
||||
description:
|
||||
"Enable prompt extend (true/false). Default: true for qwen-image sync models; omit for async.",
|
||||
description: BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE,
|
||||
},
|
||||
{
|
||||
flag: "--watermark <bool>",
|
||||
description: "Enable watermark (true/false). Default: true.",
|
||||
description: BOOL_FLAG_WATERMARK,
|
||||
},
|
||||
{
|
||||
flag: "--no-wait",
|
||||
|
||||
@@ -22,6 +22,10 @@ import { poll } from "../../utils/polling.ts";
|
||||
import { downloadFile, formatBytes } from "../../utils/download.ts";
|
||||
import { promptText, failIfMissing } from "../../output/prompt.ts";
|
||||
import { emitResult, emitBare } from "../../output/output.ts";
|
||||
import {
|
||||
BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,
|
||||
BOOL_FLAG_WATERMARK,
|
||||
} from "../../utils/flag-descriptions.ts";
|
||||
|
||||
export default defineCommand({
|
||||
name: "video edit",
|
||||
@@ -55,11 +59,11 @@ export default defineCommand({
|
||||
},
|
||||
{
|
||||
flag: "--prompt-extend <bool>",
|
||||
description: "Enable prompt extend (true/false). Omit to use API default.",
|
||||
description: BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,
|
||||
},
|
||||
{
|
||||
flag: "--watermark <bool>",
|
||||
description: "Enable watermark (true/false). Default: true.",
|
||||
description: BOOL_FLAG_WATERMARK,
|
||||
},
|
||||
{ flag: "--seed <n>", description: "Random seed for reproducible generation", type: "number" },
|
||||
{ flag: "--download <path>", description: "Save video to file on completion" },
|
||||
|
||||
@@ -23,6 +23,10 @@ import { downloadFile, formatBytes } from "../../utils/download.ts";
|
||||
import { runConcurrent, getConcurrency } from "../../utils/concurrent.ts";
|
||||
import { promptText, failIfMissing } from "../../output/prompt.ts";
|
||||
import { emitResult, emitBare } from "../../output/output.ts";
|
||||
import {
|
||||
BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,
|
||||
BOOL_FLAG_WATERMARK,
|
||||
} from "../../utils/flag-descriptions.ts";
|
||||
|
||||
// Normalize shorthand resolution (720P, 1080P) to pixel format for video generation models
|
||||
const RESOLUTION_SHORTCUTS: Record<string, string> = {
|
||||
@@ -62,11 +66,11 @@ export default defineCommand({
|
||||
},
|
||||
{
|
||||
flag: "--prompt-extend <bool>",
|
||||
description: "Enable prompt extend (true/false). Omit to use API default.",
|
||||
description: BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,
|
||||
},
|
||||
{
|
||||
flag: "--watermark <bool>",
|
||||
description: "Enable watermark (true/false). Default: true.",
|
||||
description: BOOL_FLAG_WATERMARK,
|
||||
},
|
||||
{ flag: "--seed <n>", description: "Random seed for reproducible generation", type: "number" },
|
||||
{ flag: "--download <path>", description: "Save video to file on completion" },
|
||||
|
||||
@@ -22,6 +22,10 @@ import { poll } from "../../utils/polling.ts";
|
||||
import { downloadFile, formatBytes } from "../../utils/download.ts";
|
||||
import { promptText, failIfMissing } from "../../output/prompt.ts";
|
||||
import { emitResult, emitBare } from "../../output/output.ts";
|
||||
import {
|
||||
BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,
|
||||
BOOL_FLAG_WATERMARK,
|
||||
} from "../../utils/flag-descriptions.ts";
|
||||
|
||||
export default defineCommand({
|
||||
name: "video ref",
|
||||
@@ -65,11 +69,11 @@ export default defineCommand({
|
||||
},
|
||||
{
|
||||
flag: "--prompt-extend <bool>",
|
||||
description: "Enable prompt extend (true/false). Omit to use API default.",
|
||||
description: BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,
|
||||
},
|
||||
{
|
||||
flag: "--watermark <bool>",
|
||||
description: "Enable watermark (true/false). Default: true.",
|
||||
description: BOOL_FLAG_WATERMARK,
|
||||
},
|
||||
{ flag: "--seed <n>", description: "Random seed for reproducible generation", type: "number" },
|
||||
{ flag: "--download <path>", description: "Save video to file on completion" },
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/** Shared --foo <bool> help text; keep wording consistent across commands. */
|
||||
|
||||
export const BOOL_FLAG_WATERMARK =
|
||||
"Enable watermark (true/false). Default: true. Omit to use API default.";
|
||||
|
||||
/** CLI sends prompt_extend=true when flag omitted (qwen-image edit, etc.). */
|
||||
export const BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE =
|
||||
"Enable prompt extend (true/false). Default: true. Omit to use API default.";
|
||||
|
||||
/** Sync qwen-image defaults on; async models omit the field unless flag is set. */
|
||||
export const BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE =
|
||||
"Enable prompt extend (true/false). Default: true for qwen-image sync. Omit to use API default.";
|
||||
|
||||
/** CLI omits prompt_extend in the request when flag is unset (video commands). */
|
||||
export const BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT =
|
||||
"Enable prompt extend (true/false). Default: API default. Omit to use API default.";
|
||||
@@ -1,11 +1,12 @@
|
||||
import { expect, test } from "vite-plus/test";
|
||||
import { ExitCode, GLOBAL_OPTIONS } from "bailian-cli-core";
|
||||
import { parseFlags } from "../src/args.ts";
|
||||
import { BOOL_FLAG_WATERMARK } from "../src/utils/flag-descriptions.ts";
|
||||
|
||||
const IMAGE_GENERATE_OPTIONS = [
|
||||
{ flag: "--prompt <text>", description: "Image description", required: true },
|
||||
{ flag: "--model <model>", description: "Model ID" },
|
||||
{ flag: "--watermark <bool>", description: "Enable watermark (true/false). Default: true." },
|
||||
{ flag: "--watermark <bool>", description: BOOL_FLAG_WATERMARK },
|
||||
];
|
||||
|
||||
test("parseFlags rejects unknown long flags", () => {
|
||||
|
||||
Reference in New Issue
Block a user