Download src/infra/cli-root-options.ts from Darochin/openskynet: direct link, hf CLI and curl.
- Browser
- Download file 785 Bytes
-
https://huggingface.co/Darochin/openskynet/resolve/7e708f8da03fdeb42cb747523f87d1bed5cd0805/src/infra/cli-root-options.ts
- Command line
-
hf download hf://Darochin/openskynet@7e708f8da03fdeb42cb747523f87d1bed5cd0805/src/infra/cli-root-options.ts
-
curl -L -o cli-root-options.ts https://huggingface.co/Darochin/openskynet/resolve/7e708f8da03fdeb42cb747523f87d1bed5cd0805/src/infra/cli-root-options.ts
785 Bytes
| export const FLAG_TERMINATOR = "--"; | |
| const ROOT_BOOLEAN_FLAGS = new Set(["--dev", "--no-color"]); | |
| const ROOT_VALUE_FLAGS = new Set(["--profile", "--log-level"]); | |
| export function isValueToken(arg: string | undefined): boolean { | |
| if (!arg || arg === FLAG_TERMINATOR) { | |
| return false; | |
| } | |
| if (!arg.startsWith("-")) { | |
| return true; | |
| } | |
| return /^-\d+(?:\.\d+)?$/.test(arg); | |
| } | |
| export function consumeRootOptionToken(args: ReadonlyArray<string>, index: number): number { | |
| const arg = args[index]; | |
| if (!arg) { | |
| return 0; | |
| } | |
| if (ROOT_BOOLEAN_FLAGS.has(arg)) { | |
| return 1; | |
| } | |
| if (arg.startsWith("--profile=") || arg.startsWith("--log-level=")) { | |
| return 1; | |
| } | |
| if (ROOT_VALUE_FLAGS.has(arg)) { | |
| return isValueToken(args[index + 1]) ? 2 : 1; | |
| } | |
| return 0; | |
| } | |