Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Adding help flag and adjusting command builders to make them clearer #59

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
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
1 change: 1 addition & 0 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function Command(commands) {
args = args.command(commands[command]);
});

args = args.help();
this.args = args;
};

Expand Down
5 changes: 5 additions & 0 deletions lib/commands/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ var command = {
all: {
type: "boolean",
default: false
},
network: {
type: 'string',
description: 'Specify the network to use, saving artifacts specific to that network',
default: 'development'
}
},
run: function (options, done) {
Expand Down
12 changes: 11 additions & 1 deletion lib/commands/console.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
var command = {
command: 'console',
description: 'Run a console with contract abstractions and commands available',
builder: {},
builder: {
'verbose-rpc' : {
type: 'boolean',
default: false
},
'network' : {
type: 'string',
description: 'Specify the network to use, saving artifacts specific to that network',
default: 'development'
}
},
run: function (options, done) {
var Config = require("truffle-config");
var Console = require("../console");
Expand Down
9 changes: 2 additions & 7 deletions lib/commands/create.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
var command = {
command: 'create',
command: 'create <type> <name>',
description: 'Helper to create new contracts, migrations and tests',
builder: {
all: {
type: "boolean",
default: false
}
},
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var ConfigurationError = require("../errors/configurationerror");
Expand Down
9 changes: 5 additions & 4 deletions lib/commands/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ var command = {
command: 'debug',
description: 'Interactively debug any transaction on the blockchain (experimental)',
builder: {
_: {
type: "string"
"transaction": {
type: "string",
describe: "Hash of transaction to be debugged"
}
},
run: function (options, done) {
Expand All @@ -19,11 +20,11 @@ var command = {
Environment.detect(config, function(err) {
if (err) return done(err);

if (config._.length == 0) {
if (!config.transaction) {
return done(new Error("Please specify a transaction hash as the first parameter in order to debug that transaction. i.e., truffle debug 0x1234..."));
}

var tx_hash = config._[0];
var tx_hash = config.transaction;

var bugger = new Debugger(config);
var lastCommand = "n";
Expand Down
12 changes: 5 additions & 7 deletions lib/commands/exec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
var command = {
command: 'exec',
command: 'exec <file>',
description: 'Execute a JS module within this Truffle environment',
builder: {
file: {
type: "string"
network: {
description: 'Specify the network to use, using artifacts specific to that network.',
type: 'string',
default: 'development'
}
},
run: function (options, done) {
Expand All @@ -18,10 +20,6 @@ var command = {

var file = options.file;

if (file == null && options._.length > 0) {
file = options._[0];
}

if (file == null) {
done(new ConfigurationError("Please specify a file, passing the path of the script you'd like the run. Note that all scripts *must* call process.exit() when finished."));
return;
Expand Down
6 changes: 1 addition & 5 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
var command = {
command: 'install',
command: 'install [packages...]',
description: 'Install a package from the Ethereum Package Registry',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var Package = require("../package");

if (options._ && options._.length > 0) {
options.packages = options._;
}

var config = Config.detect(options);
Package.install(config, done);
}
Expand Down
12 changes: 11 additions & 1 deletion lib/commands/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ var command = {
builder: {
reset: {
type: "boolean",
describe: 'Run all migrations from the beginning, instead of running from the last completed migration',
default: false
},
"compile-all": {
describe: "recompile all contracts",
describe: "Recompile all contracts",
type: "boolean",
default: false
},
Expand All @@ -19,6 +20,15 @@ var command = {
f: {
describe: "Specify a migration number to run from",
type: "number"
},
network: {
describe: "Network to deploy to",
type: "string"
},
'verbose-rpc': {
describe: 'Log communication between Truffle and the RPC.',
type: "boolean",
default: false
}
},
run: function (options, done) {
Expand Down
17 changes: 4 additions & 13 deletions lib/commands/opcode.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
var command = {
command: 'opcode',
description: 'Print the compiled opcodes for a given contract',
builder: {
all: {
type: "boolean",
default: false
}
},
command: 'opcode <contract>',
description: 'Print the compiled opcodes for the given contract',
builder: {},
run: function (options, done) {
var Config = require("truffle-config");
var TruffleError = require("truffle-error");
var Contracts = require("../contracts");
var CodeUtils = require("truffle-code-utils");

if (options._.length == 0) {
return done(new TruffleError("Please specify a contract name."));
}

var config = Config.detect(options);
Contracts.compile(config, function(err) {
if (err) return done(err);

var contractName = options._[0];
var contractName = options.contract;
var Contract;
try {
Contract = config.resolver.require(contractName);
Expand Down
5 changes: 5 additions & 0 deletions lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ var command = {
port: {
alias: "p",
default: "8080"
},
network: {
type: 'string',
description: 'Specify the network to use, using artifacts specific to that network',
default: 'development'
}
},
run: function (options, done) {
Expand Down
18 changes: 17 additions & 1 deletion lib/commands/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
var command = {
command: 'test',
description: 'Run Mocha and Solidity tests',
builder: {},
builder: {
'compile-all': {
type: 'boolean',
description: 'Compile all contracts instead of intelligently choosing',
default: false
},
'verbose-rpc': {
type: 'boolean',
description: 'Log communication between Truffle and the RPC',
default: false
},
network: {
type: 'string',
description: 'Specify the network to use, using artifacts specific to that network',
default: 'development'
}
},
run: function (options, done) {
var OS = require("os");
var dir = require("node-dir");
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/unbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function formatCommands(commands) {
}

var command = {
command: 'unbox',
command: 'unbox <box>',
description: 'Unbox Truffle project',
builder: {},
run: function(options, done) {
Expand All @@ -60,7 +60,7 @@ var command = {
logger: console
});

var url = normalizeURL(options._[0]);
var url = normalizeURL(options.box);

Box.unbox(url, config.working_directory, {logger: config.logger})
.then(function(boxConfig) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"truffle-resolver": "^4.0.0",
"truffle-solidity-utils": "^1.1.0",
"web3": "^0.20.1",
"yargs": "^6.6.0"
"yargs": "^8.0.0"
},
"bin": {
"truffle": "./cli.js",
Expand Down