-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve command readability (#12)
* add helper function to change output command syntax * rename contractAddress for address in wasm usage * add helper function to keys networks and wasm * update readme output * add getVersion util in order to use package json version * bump 0.1.6 version
- Loading branch information
Showing
10 changed files
with
56 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import { Command } from "commander"; | ||
import { Command, Help } from "commander"; | ||
import UploadCommand from "./upload"; | ||
import InstantiateCommand from "./instantiate"; | ||
import QueryCommand from "./query"; | ||
import ExecuteCommand from "./execute"; | ||
import subcommandTerm from "../../utils/subcommandTerm"; | ||
|
||
export default new Command("wasm") | ||
const t = new Help(); | ||
|
||
const WasmCommand = new Command("wasm") | ||
.description("Wasm transaction subcommands") | ||
.usage("[command]") | ||
.argument("[command]") | ||
.addCommand(UploadCommand) | ||
.addCommand(QueryCommand) | ||
.addCommand(ExecuteCommand) | ||
.addCommand(InstantiateCommand); | ||
|
||
WasmCommand.addHelpCommand(false).configureHelp({ subcommandTerm }); | ||
|
||
export default WasmCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { Command } from "commander"; | ||
import { Command, Help } from "commander"; | ||
import { queryContract } from "../../services/wasm.service"; | ||
import NetworkOption from "../options/network"; | ||
|
||
export default new Command("query") | ||
.description("Querying commands for contracts") | ||
.usage("<contractAddress> <msg> [options]") | ||
.argument("<contractAddress>") | ||
.usage("<address> <msg> [options]") | ||
.argument("<address>") | ||
.argument("<msg>") | ||
.addOption(NetworkOption) | ||
.action(queryContract); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
export default () => JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json"), "utf8")).version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Argument, Command } from "commander"; | ||
|
||
export default (cmd: Command & { _name: string; _aliases: string[]; _args: Argument[] }) => { | ||
const args = cmd._args | ||
.map((arg: Argument) => { | ||
const nameOutput = arg.name() + (arg.variadic === true ? "..." : ""); | ||
|
||
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]"; | ||
}) | ||
.join(" "); | ||
return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (args ? " " + args : ""); | ||
}; |