Skip to content

Commit

Permalink
Better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedgreen committed Dec 26, 2021
1 parent 1112893 commit 08146a4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@ import { ArgumentError, HelpError } from "./error.ts";
import { leftPad } from "./fmt.ts";

export interface ArgumentOptions {
// If `flags` is set, the argument is passed
// as a named flag, e.g. `--name value`. Otherwise,
// the argument will be an anonymous positional
// argument.
/**
* If `flags` is set, the argument is passed
* as a named flag, e.g. `--name value`. Otherwise,
* the argument will be an anonymous positional
* argument.
*/
readonly flags: string[];

// A description to display in the generated
// help messages.
/**
* A description to display in the generated
* help messages.
*/
readonly description?: string;
}

export interface FlagOptions {
// A set of aliases for the flag's `name`. If
// any of the aliases, or `--{name}` are passed,
// the flag is set to true.
/**
* A set of aliases for the flag's `name`. If
* any of the aliases, or `--{name}` are passed,
* the flag is set to true.
*/
readonly aliases?: string[];

// A description to display in the generated
// help messages.
/**
* A description to display in the generated
* help messages.
*/
readonly description?: string;
}

Expand Down
16 changes: 16 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
/**
* A parser that can read a single argument
* value.
*
* Implement this interface to provide parsers
* for custom argument types.
*/
export interface ArgumentType<T> {
/**
* Function which parses a single argument. If
* the parsing fails, this should throw an error.
*/
readonly parse: (raw: string) => T;

/**
* Type name to use when displaying help and
* error messages.
*/
readonly typeName: string;
}

Expand Down

0 comments on commit 08146a4

Please sign in to comment.