{"record":{"id":"8001aa34b97261dc","repo":"can1357/oh-my-pi","slug":"alias-requires-a-command-name","errorCode":null,"errorMessage":"--alias requires a command name","messagePattern":"--alias requires a command name","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/profile-bootstrap.ts","lineNumber":131,"sourceCode":"\t\t\t}\n\t\t\tprofile = value;\n\t\t\tinsertBoundaryBeforeNextValue = needsBoundaryAfterGlobalStrip(stripped);\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith(\"--profile=\")) {\n\t\t\tconst value = arg.slice(\"--profile=\".length);\n\t\t\tif (!value) {\n\t\t\t\tthrow new Error(\"--profile requires a profile name\");\n\t\t\t}\n\t\t\tprofile = value;\n\t\t\tinsertBoundaryBeforeNextValue = needsBoundaryAfterGlobalStrip(stripped);\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--alias\") {\n\t\t\tconst value = argv[index + 1];\n\t\t\tif (!value || value.startsWith(\"-\")) {\n\t\t\t\tthrow new Error(\"--alias requires a command name\");\n\t\t\t}\n\t\t\taliasName = value;\n\t\t\tinsertBoundaryBeforeNextValue = needsBoundaryAfterGlobalStrip(stripped);\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith(\"--alias=\")) {\n\t\t\tconst value = arg.slice(\"--alias=\".length);\n\t\t\tif (!value) {\n\t\t\t\tthrow new Error(\"--alias requires a command name\");\n\t\t\t}\n\t\t\taliasName = value;\n\t\t\tinsertBoundaryBeforeNextValue = needsBoundaryAfterGlobalStrip(stripped);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Known string flags normally consume flag-looking values (for example\n\t\t// `--system-prompt --profile foo` means the system prompt is literally","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/profile-bootstrap.ts#L113-L149","documentation":"extractProfileFlags saw a bare `--alias` flag with no following command name — the next argv element is absent or begins with `-`. A managed alias must have a concrete name, so parsing aborts with this targeted error.","triggerScenarios":"Invoking `omp --profile work --alias` (end of argv) or `omp --alias --profile work` where the token after `--alias` is another flag.","commonSituations":"Re-running a command from history where the alias name was lost; swapping flag order and forgetting the value; scripts with an empty alias variable followed by more flags.","solutions":["Supply the alias name: `omp --profile <name> --alias <aliasName>`","Use `--alias=<name>` to bind the value explicitly","Reorder flags so the alias name directly follows --alias"],"exampleFix":"// before\nomp --profile work --alias\n// after\nomp --profile work --alias work","handlingStrategy":"validation","validationCode":"const i = argv.indexOf(\"--alias\");\nif (i !== -1) {\n  const v = argv[i + 1];\n  if (!v || v.startsWith(\"-\")) throw new Error(\"--alias requires a name: use --alias <name> or --alias=<name>\");\n}","typeGuard":"function aliasFlagHasValue(argv: string[]): boolean {\n  const i = argv.indexOf(\"--alias\");\n  return i === -1 || (i + 1 < argv.length && !argv[i + 1].startsWith(\"-\"));\n}","tryCatchPattern":"try {\n  await runCli(argv);\n} catch (err) {\n  if (err instanceof Error && err.message === \"--alias requires a command name\") {\n    console.error(\"Usage: omp --profile <name> --alias <aliasName>\");\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["Always give --alias a value in the same token sequence; never let a flag follow it directly","Validate ALIAS_NAME variables are non-empty in wrapper scripts","Prefer --alias=<name> for unambiguous binding"],"tags":["cli","argument-validation","alias","parsing"],"backgroundTag":"missing-required-argument","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}