Closed piotrmurach closed 8 years ago
Just food for thought. Again, probably worth having some very simple examples in the beginning that entice everyone currently stuck with bash.
Hi Adam, would you have time to come up with some interesting examples? If this lib is to be used I think good examples are crucial.
Examples for the doc, or examples where these options are not necessary? I might have some time tomorrow evening to work on this. :)
How about something like this as an EXAMPLE section right after USAGE?
cmd = TTY::Command.new
# dependencies
cmd.execute! "apt-get -y install build-essential checkinstall"
# fetch ruby if necessary
if !File.exists?("ruby-2.3.0.tar.gz")
puts "Downloading..."
cmd.execute! "wget http://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz"
cmd.execute! "tar xvzf ruby-2.3.0.tar.gz"
end
# now install
Dir.chdir("ruby-2.3.0") do
puts "Building..."
cmd.execute! "./configure --prefix=/usr/local"
cmd.execute! "make"
end
Sorry Adam, I haven't ignored you! I've been travelling around Hungary and decided to take a break from oss stuff during my holidays.
I suppose in my comment I was referring to docs, and specificically to your real world usage/experience. I think the above is a great example. My usual way of writting readmes is to provide example section after the api interface, and since the contents menu is the first thing people see they should have no problem jumping to sections, but of course this is not a hard rule. Also, feel free to add code snippets to examples folder so that people can play with.
No worries, I'm busy too. :)
I have more elaborate examples but I wanted to come up with something that was a little more self-contained and understandable. This example could also use result.success?
to see if ruby is already installed, for example.
I'll put together a PR for the readme. Code snippets might work too but it's hard to make them practical because they will actually be running on someone's machine! BTW, is there a tool you use to generate the table of contents in the markdown, or is that done by hand?
The contents menu is lovingly crafted by hand using github anchor tags for references.
For checking if executables exist we could show example using tty-which which is a bit nicer than running which ruby
directly and then checking success code? I suppose, we could demonstrate both and discuss prons/cons.
My intention is to fully document what we have now and prepare first release for next week. I plan to release frequently and I'm hoping to open this library to wider feedback and usage. If you find a minute to work on anything to help make this release that would be really appreciated.
Sure, I'd be happy to help. Give me another task! I usually have a bit of time in the evenings to pitch in. I wonder if we should rename execute!
to try_execute or something... Not to mention updating the README.
Before release I think it would be good to resolve all the open issues. I see the documentation still lacking quite a bit, not to mention test coverage. Anything that you can tackle will be great.
I've added gitter link to general tty chat room, hopefully we chat there as well to discuss things for future improvements and different tty packages.
Let's close this one!