Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First pass at basic usage API and design #1

Merged
merged 2 commits into from
Aug 17, 2012
Merged

Conversation

kellyredding
Copy link
Member

Usage

Create a command object:

cmd = Scmd.new("echo hi")

cmd.to_s    #=> "echo hi"
cmd.inspect #=> #<Scmd::Command:0x83220514 @cmd_str="echo hi" @exitcode=nil>

cmd.pid      #=> nil
cmd.exitcode #=> nil
cmd.stdout   #=> ''
cmd.stderr   #=> ''

Run it:

cmd.run

Results:

# written to the cmd instance
cmd.pid      #=> 12345
cmd.exitcode #=> 0
cmd.stdout   #=> 'hi'
cmd.stderr   #=> ''

# the cmd instance is returned by `run` for chaining as well
cmd.run.stdout #=> 'hi'

Some helpers:

puts cmd.stderr if !cmd.success?

Raise an exception if not successful with run!:

Scmd.new("cd /path/that/does/not/exist").run! #=> Scmd::Command::Failure

@kellyredding
Copy link
Member Author

/cc @teaminsight/admins

cmd = Scmd.new("echo hi")

cmd.to_s #=> "echo hi"
cmd.inspect #=>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the inspect return nothing / empty string? Curious if that's what you are trying to convey.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcredding - No, haven't gotten that far yet :)

On Fri, Aug 17, 2012 at 12:03 PM, Collin Redding
notifications@github.comwrote:

In README.md:

@@ -18,7 +18,79 @@ Or install it yourself as:

Usage

-TODO: Write usage instructions here
+Create a command object:
+
+```ruby
+cmd = Scmd.new("echo hi")
+
+cmd.to_s #=> "echo hi"
+cmd.inspect #=>

Does the inspect return nothing / empty string? Curious if that's what you
are trying to convey.


Reply to this email directly or view it on GitHubhttps://github.com/teaminsight/scmd/pull/1/files#r1404734.

@jcredding
Copy link
Member

@kellyredding - Overall, README looks good to me.

@kellyredding
Copy link
Member Author

Guys - this is ready for review, please. I scaled back the README and API a bit - took out the logging and pretend mode stuff (for now at least). Don't want to do too much too soon.

I'm going to start putting this into our systems and see what else needs extracting.

@jcredding
Copy link
Member

@kellyredding - Looks good to me.

kellyredding added a commit that referenced this pull request Aug 17, 2012
First pass at basic usage API and design
@kellyredding kellyredding merged commit 039eccd into master Aug 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants