piotrmurach / tty-command

Execute shell commands with pretty output logging and capture stdout, stderr and exit status.
https://ttytoolkit.org
MIT License
400 stars 34 forks source link

grab bag of feedback #3

Closed gurgeous closed 8 years ago

gurgeous commented 8 years ago

This is neat! Some quick thoughts after a few minutes of poking around. I really like it, so please don't take any of this feedback as negative. It's much easier to list the stuff that stood out rather than comment on the overall package, which is excellent. Thanks for putting this together!

[71555-047a57b2] Running ls hello world
[71555-047a57b2]    ls: hello: No such file or directory
[71555-047a57b2]    ls: world: No such file or directory
[71555-047a57b2] Finished in 0.002 seconds with exit status 1 (failed)

Here's a typical example, one of hundreds that I have from my old startup. Think about this snippet - would it make sense to separate out every argument? Would it make sense for the script to continue after failure? Would it make sense to replace shell redirects/pipes with a custom syntax? Just some food for thought.

  # restore db
  def db
    if Util.mac?
      chmod, dst_dir = "#{user}:admin", "/usr/local/var/mongodb"
    else
      chmod, dst_dir = "mongodb", "/var/lib/mongodb"
    end

    Util.rm_and_mkdir(TMP)
    Dir.chdir(TMP) do
      # untar
      banner "Untarring #{db_src}..."
      run("tar xvfz #{db_src} --exclude 'prealloc*'")

      # atomically move the files into place
      with_db_stopped do
        Dir.chdir("mongodb") do
          Dir["startup*"].sort.each do |src|
            next if src == "lost+found"
            next if src =~ /\.old$/

            dst = "#{dst_dir}/#{src}"
            old = "#{dst}.old"
            run "sudo rm -rf #{old}"
            run "sudo mv #{dst} #{old}" if File.exist?(dst)
            run "sudo chown #{chmod} #{src}"
            run "sudo mv #{src} #{dst}"
            run "sudo restore > /tmp/restore.txt"
          end
        end
      end
    end
  end

Happy to help implement any/all changes... Thanks again!

piotrmurach commented 8 years ago

Thanks, that's great feedback!

Few initial thoughts:

piotrmurach commented 8 years ago

On another note, it would be great to open up separate issues for each bullet point. Then we are able to reference commits against features. I should be able to find some time tomorrow.

piotrmurach commented 8 years ago

I've moved all the feedback to separate issues.