25. ~ > rails
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
~ >
44. ~ > git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
If you often merge with the same branch, you may want to
use something like the following in your configuration file:
[branch "master"]
remote = <nickname>
merge = <remote-ref>
[remote "<nickname>"]
url = <url>
fetch = <refspec>
See git-config(1) for details.
50. ~ > gem uninstall rspec
You have requested to uninstall the gem:
rspec-2.8.0
cucumber-1.1.4 depends on [rspec (>= 2.7.0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] n
51. ~ > gem uninstall rspec
You have requested to uninstall the gem:
rspec-2.8.0
cucumber-1.1.4 depends on [rspec (>= 2.7.0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] n
~ > gem uninstall -I rspec
52. ~ > gem uninstall rspec
You have requested to uninstall the gem:
rspec-2.8.0
cucumber-1.1.4 depends on [rspec (>= 2.7.0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] n
~ > gem uninstall -I rspec
Successfully uninstalled rspec-2.8.0
88. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
89. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
~ > myapp help test:example
Usage:
thor test:example FILE
Options:
-d, [--delete=DELETE] # Delete the file after parsing it
an example task
90. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
~ > myapp help test:example
Usage:
thor test:example FILE
Options:
-d, [--delete=DELETE] # Delete the file after parsing it
an example task
91. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
~ > myapp help test:example
Usage:
thor test:example FILE
Options:
-d, [--delete=DELETE] # Delete the file after parsing it
an example task
92. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
~ > myapp help test:example
Usage:
thor test:example FILE
Options:
-d, [--delete=DELETE] # Delete the file after parsing it
an example task
93. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
~ > myapp help test:example
Usage:
thor test:example FILE
Options:
-d, [--delete=DELETE] # Delete the file after parsing it
an example task
94. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
~ > myapp help test:example
Usage:
thor test:example FILE
Options:
-d, [--delete=DELETE] # Delete the file after parsing it
an example task
95. class Test < Thor
desc " FILE", "an example task"
method_option :delete,
:aliases => "-d",
:desc => "Delete the file"
def example(file)
end
end
~ > myapp help test:example
Usage:
thor test:example FILE
Options:
-d, [--delete=DELETE] # Delete the file after parsing it
an example task
task oriented v/s feature oriented\n(ssh is feature / rails is tasks)\n\nOther Examples -- knife & cucumber\nTODO: SSH\n
\n
\n
\n
\n
\n
\n
bundle is a bad example\n\nrails/git/knife are good examples\n\n
\n
\n
all commands should be reversible, those that are not should be called out.\n\nSometimes irreversibility is unavoidable >> rm -rf --no-preserve-root /\n\n
make an example for rails generate /destroy\n
make an example for rails generate /destroy\n
make an example for rails generate /destroy\n
make an example for rails generate /destroy\n
Assume defaults wherever you can.\nIn case of risky operations don&#x2019;t assume anything.\n\nE. g. -- package managers assume latest version\n
\n
\n
\n
git add\n> did you mean `git add .&#x2019; ?\n
\n
\n
vi modes\nbehavior should not depend on hidden state\n
\n
\n
\n
\n
\n
\n
git is a very mature cli. no piping or redirection normally used. but it honors everything.\nwrite errors to stderr\n
\n
\n
\n
\n
\n
\n
\n
knife, rails, gem, bundle\n
\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
Input - command line -> Option Parsing\n\nOutput - status code, stdout, stderr\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Enforces OO\nAutomatic rake style tasks\n
Enforces OO\nAutomatic rake style tasks\n
Enforces OO\nAutomatic rake style tasks\n
Convention -- \nfirst arg to the description becomes the input \nsecond arg is the banner\n
Convention -- \nfirst arg to the description becomes the input \nsecond arg is the banner\n
Convention -- \nfirst arg to the description becomes the input \nsecond arg is the banner\n
Option Parsing\nInbuilt support for help and banners\nSupports standard invocations of help on the shell\n
Option Parsing\nInbuilt support for help and banners\nSupports standard invocations of help on the shell\n
\n
\n
\n
\n
Input - mostly handled by the third party library.\nTesting that would be testing the gem. Not a good idea.\n\n
Input - mostly handled by the third party library.\nTesting that would be testing the gem. Not a good idea.\n\n
Standard Ruby classes. Libraries like test/unit, rspec.\nMocking and proxy layers for 3rd party services etc.\nLike any other app.\n\n
\n
Mocking\n&#xA0; mocha works out well.&#xA0;\n&#xA0; For filesystem, MockFS lets you mock the entire file system.&#xA0;\n\nTesting CLI apps that manipulate filesystem. Mocking is good. But if we mock every call to FileUtils, test becomes very tightly coupled. So even if behaviour doesn't change but the command changes the test breaks.\n&#xA0;- one use FakeFS\n\n
Isolate environment of its own.\nIf its is cheap and scriptable to spin up the environment. Then we can have behaviour testing&#xA0;\n&#xA0; - powerful machines.\n&#xA0; - strong virtualizations (inbuilt)\nvagrant, lxc, openvz\n
2 distinct sections -- your and subprocesses\n\nbackticks and system ruby calls not versatile. Doesn&#x2019;t give you full control over the Input/Output/Error stream\nMixLib::Shellout and POpen3 are better alternatives.\nRespect exit status 0 -for success, rest all failures while writing your CLI.\nYour CLI should write error to stderr and not stdout. ruby provides $stdout, $stdin, $stderr\n\n
\n
\n
\n
Compatible with windows.\nUses the select(2) system call. \nGives abstractions over umask, cwd etc.\n
Compatible with windows.\nUses the select(2) system call. \nGives abstractions over umask, cwd etc.\n
Drop in plugins eg. vagrant, knife\nPick up all .rb files from a predetermined location.\n\nYour CLI app can then be easily extended\nWhen writing an app, you don&#x2019;t know all the possible use cases\n\n
Provide hooks where arbitrary code can be run on failure and success of steps.\nEnsure that you support all executable files and not only .rb files.\n\nCan be filename based (git) or configurable.\n
STDOUT could be the default. But should be configurable to a file. \n\nLog at correct level. Apply to all apps but worth mentioning.\n\nyou may want to support -v and -vv for falling back to :info or :debug and -q falls back fatal.\n