Package Exports
- @hammerhq/cli-tool
- @hammerhq/cli-tool/hammer/main.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hammerhq/cli-tool) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@hammerhq/cli-tool
🏷️ CLI tool for everyone!
📥 Installation
Using hammer:
$ hammer install TheHammerHQ/cli-toolUsing yarn:
$ yarn add @hammerhq/cli-toolUsing npm:
$ npm install @hammerhq/cli-tool🔧 Usage
cliTool
.createCommand(ICommand, callback(args) => any) // create command
.createCommand(ICommand, callback(args) => any) // create another command
.help() // If none of the above commands are used, execute the help command.ICommand: Where command is defined to be used when separating arguments. Structure:
interface ICommand {
name: string;
usage: string;
example: string[];
category: string;
aliases: string[];
description: string;
options: OptionDefinition[];
}OptionDefinition: Where options are defined to be used when separating arguments. Structure:
interface OptionDefinition {
name: string;
type?: ((input: string) => any) | undefined;
alias?: string | undefined;
multiple?: boolean | undefined;
lazyMultiple?: boolean | undefined;
defaultOption?: boolean | undefined;
defaultValue?: any;
group?: string | string[] | undefined;
}callback(args) => unknown: If the command you set is used, the action to be applied. Example:
cliTool.createCommand(ICommand, (args) => {
console.log("You used command with arguments", args);
});🛠️ Example
import cliTool from "@hammerhq/cli-tool";
cliTool
.createCommand({
name: "install",
usage: "<module_name> [--version] <package_version>",
example: [ "@hammerhq/cli-tool", "bargs --version 1.0.1" ],
category: "utility",
aliases: [ "i", "add" ],
description: "Install packages from server",
options: [
{ name: "module", type: String },
{ name: "version", type: String }
]
}, (commandName, args) => {
const { module, version } = args;
console.log("You have downloaded package", module, "with version" version ? version : "latest");
})
.help()🔗 Contributing / Issues / Ideas
Feel free to use GitHub's features ✨