Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import {Section} from './src/models/section';
import {Argument} from './src/models/argument';
import {ArgumentType} from './src/types/argumentType';

import { UsageInterface } from './src/interface/Usage';
import { SectionInterface } from './src/interface/Section';
import { CommandInterface } from './src/interface/Command';
import { ArgumentInterface } from './src/interface/Argument';

// tslint:disable-next-line:no-default-export
export default UsageParser;
export {Usage, Group, Section, Argument, ArgumentType};
export {
Usage, Group, Section, Argument, ArgumentType,
UsageInterface, SectionInterface, CommandInterface, ArgumentInterface
};
64 changes: 64 additions & 0 deletions src/interface/Argument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { UsageProperty } from "./UsageProperty";
import { ArgumentType } from "../types/argumentType";

export interface ArgumentInterface extends UsageProperty {
/**
* The full name of the argument
* @type {?string | undefined}
*/
longName?: string | undefined;

/**
* The short name of the argument
* @type {?string | undefined}
*/
shortName?: string | undefined;

/**
* The description of the argument
* @type {?string | undefined}
*/
description? : string | undefined;

/**
* The type of argument
* @type {ArgumentType | undefined}
*/
type: ArgumentType | undefined;

/**
* The possible values of argument
* @type {?string[] | undefined}
*/
values?: string[] | undefined;

/**
* The default value of argument
* @type {?string | undefined}
*/
default?: string | undefined;

/**
* The argument is required
* @type {?boolean | undefined}
*/
required?: boolean | undefined;

/**
* The argument has value
* @type {?boolean | undefined}
*/
hasValue?: boolean | undefined;

/**
* The delimiter of argument
* @type {?string | undefined}
*/
delimiter?: string | undefined;

/**
* The argument has deprecated
* @type {?boolean | undefined}
*/
deprecated?: boolean | undefined;
}
22 changes: 22 additions & 0 deletions src/interface/Command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { UsageInterface } from "./Usage";
import { UsageProperty } from "./UsageProperty";

export interface CommandInterface extends UsageProperty {
/**
* The command name
* @type {string}
*/
command: string | undefined;

/**
* The command description
* @type {?string | undefined}
*/
description?: string | undefined;

/**
* The commands usage
* @type {?Usage | undefined}
*/
usage?: UsageInterface | undefined;
}
15 changes: 15 additions & 0 deletions src/interface/Section.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { UsageProperty } from "./UsageProperty";

export interface SectionInterface {
/**
* Name of section
* @type {string | undefined}
*/
name?: string | undefined;

/**
* Array of properties
* @type {string[]}
*/
properties: UsageProperty[];
}
21 changes: 21 additions & 0 deletions src/interface/Usage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SectionInterface } from "./Section";

export interface UsageInterface {
/**
* Array of Section object
* @type {Section[]}
*/
sections: SectionInterface[];

/**
* Global delimiter of usage's doc
* @type {?string | undefined}
*/
delimiter?: string | undefined;

/**
* Examples of usage
* @type {?string[] | undefined}
*/
examples?: string[] | undefined;
}
4 changes: 2 additions & 2 deletions src/models/argument.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {config} from '../config';
import {ArgumentType} from '../types/argumentType';
import {ArgumentTypes} from './argumentTypes';
import {UsageProperty} from '../interface/UsageProperty';
import { ArgumentInterface } from '../interface/Argument';

import '../extensions/String';

/** Argument object of usage's doc */
export class Argument implements UsageProperty {
export class Argument implements ArgumentInterface {
/**
* The full name of the argument
* @type {?string | undefined}
Expand Down
4 changes: 2 additions & 2 deletions src/models/command.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Usage} from "./usage";
import {UsageProperty} from '../interface/UsageProperty';
import { CommandInterface } from "../interface/Command";

/**
* The command with name, description and usage, if they exist
*/
class Command implements UsageProperty {
class Command implements CommandInterface {

/**
* The command name
Expand Down
3 changes: 2 additions & 1 deletion src/models/section.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {UsageProperty} from "../interface/UsageProperty";
import { SectionInterface } from "../interface/Section";

import '../interface/String';

/** The section with properties of usage's doc */
export class Section {
export class Section implements SectionInterface {

/**
* Name of section
Expand Down
3 changes: 2 additions & 1 deletion src/models/usage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {Section} from './section';
import { UsageInterface } from '../interface/Usage';

/**
* The Usage is a Object which contains Section of doc
*/
export class Usage {
export class Usage implements UsageInterface {

/**
* Array of Section object
Expand Down