Skip to content

Commit 23498e0

Browse files
committed
cli fixes
1 parent 0fa9af7 commit 23498e0

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

packages/hub/cli.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ const commands = {
7373
description:
7474
"This will create an empty branch and upload the files to it. This will erase all previous commits on the branch if it exists.",
7575
},
76+
{
77+
name: "commit-message" as const,
78+
description: "The commit message to use. Defaults to 'Add [x] files'",
79+
},
7680
{
7781
name: "token" as const,
7882
description:
@@ -134,7 +138,8 @@ async function run() {
134138
break;
135139
}
136140
const parsedArgs = advParseArgs(args, "upload");
137-
const { repoName, localFolder, repoType, revision, fromEmpty, fromRevision, token, quiet } = parsedArgs;
141+
const { repoName, localFolder, repoType, revision, fromEmpty, fromRevision, token, quiet, commitMessage } =
142+
parsedArgs;
138143

139144
if (revision && (fromEmpty || fromRevision)) {
140145
await createBranch({
@@ -152,6 +157,8 @@ async function run() {
152157
files: [pathToFileURL(localFolder)],
153158
branch: revision,
154159
accessToken: token,
160+
commitTitle: commitMessage?.trim().split("\n")[0],
161+
commitDescription: commitMessage?.trim().split("\n").slice(1).join("\n").trim(),
155162
})) {
156163
if (!quiet) {
157164
console.log(event);
@@ -272,12 +279,14 @@ function advParseArgs<C extends Command>(
272279
throw new Error(`Unknown option: ${token.name}`);
273280
}
274281

275-
if (!token.value) {
276-
throw new Error(`Missing value for option: ${token.name}`);
277-
}
282+
if (!arg.boolean) {
283+
if (!token.value) {
284+
throw new Error(`Missing value for option: ${token.name}: ${JSON.stringify(token)}`);
285+
}
278286

279-
if (arg.enum && !arg.enum.includes(token.value)) {
280-
throw new Error(`Invalid value for option ${token.name}. Expected one of: ${arg.enum.join(", ")}`);
287+
if (arg.enum && !arg.enum.includes(token.value)) {
288+
throw new Error(`Invalid value for option ${token.name}. Expected one of: ${arg.enum.join(", ")}`);
289+
}
281290
}
282291

283292
return [arg.name, arg.boolean ? true : token.value];

0 commit comments

Comments
 (0)