Skip to content

Releases: albertalef/rubyshell

v1.5.0

06 Feb 00:36

Choose a tag to compare

demo

Added

  • Parallel Execution (#34)

    sh do
      results = parallel do
        curl("https://api1.example.com")
        curl("https://api2.example.com")
        chain { ls | wc("-l") }
      end
    
      results.each { |r| puts r }
    end
    • Returns an Enumerator with results in completion order
    • Supports regular commands, chains, and sh() calls
    • Errors are captured and returned as values (not raised)
  • Chain Options (#34)

    # Debug mode for chains
    chain(debug: true) { ls | grep("test") }
    
    # Parse chain output
    chain(parse: :json) { curl("https://api.example.com") }
  • Environment Variables (#47)

    # Command-level
    sh.npm("start", _env: { NODE_ENV: "production" })
    
    # Block-level
    sh(env: { DATABASE_URL: "postgres://localhost/db" }) do
      rake("db:migrate")
    end
    
    # Global
    RubyShell.env[:API_KEY] = "secret"
    RubyShell.config(env: { DEBUG: "true" })
  • Debug Mode (#39)

    # Global
    RubyShell.debug = true
    
    # Block scope
    RubyShell.debug { sh.ls }
    
    # Per command
    sh.git("status", _debug: true)
    # Output:
    #   Executed: git status
    #   Duration: 0.003521s
    #   Pid: 12345
    #   Exit code: 0
    #   Stdout: "On branch main..."
  • Output Parsers (#38)

    sh.cat("data.json", _parse: :json)   # => Hash
    sh.cat("config.yml", _parse: :yaml)  # => Hash
    sh.cat("users.csv", _parse: :csv)    # => Array
  • Refactored specs directory structure

v1.4.0

23 Jan 03:03

Choose a tag to compare

What's Changed

  • Added a new exe command $ rubyshell new file, that creates a file already with chmox +x

  • Added support for the "stdin" parameter, which allows us to manually pass a string or command to the stdin of another command, for example:
# Before, it could only be like this:
chain { echo("text") | xclip }

# Now it can also be like this:
xclip(_stdin: "text")

  • Added support for shell commands that have syntax not allowed in Ruby, for example "wl-copy," "notify-send."
# You can do it this way:
sh("notify-send", "hello")

  • Allowing an array in the hash params of a command
# Before, you could only do it this way:
sed "-e 'one'", "-e 'two'", "-e three"

# Now it can also be like this:
sed e: ["one", "two", "three"]

  • Corrections in the command executor: previously, if a program was terminated and for some reason its STDOUT had not been closed and was not going to receive any more data, the code would also remain stuck in that STDOUT forever (the same happened for STDERR).

  • Added the "quoted" method to strings. The idea here is to wrap a string in quotation marks so that the developer can purposely add it when entering a string in a command, for example:
grim "-g", "4123,898 1280x102" # => grim -g 4123,898 1280x102 => Invalid geometry

grim "-g", "4123,898 1280x102".quoted # => grim -g "4123,898 1280x102"

  • Added a way to not evaluate a command instantly, giving us the possibility of future evolution, example:
grim!("-g", "position", "-").to_shell # => returns: "grim -g position -"

# You can also do the following after that:
grim!("-g", "position", "-").exec

# Giving us the power to do this as well:
(ls! | wc!).exec # returns a count of files in pwd

# or this:

wc(_stdin: ls!) # returns a count of files in pwd

  • Changes were also made to the code structure.

@albertalef in #29

Full Changelog: v1.3.5...v1.4.0

v1.3.5

20 Jan 16:07

Choose a tag to compare

Version 1.3.5

v1.3.4

20 Jan 15:59

Choose a tag to compare

Version 1.3.4

v1.3.3

20 Jan 15:53

Choose a tag to compare

Version 1.3.3

v1.3.2

20 Jan 15:50

Choose a tag to compare

Version 1.3.2

v1.3.1

19 Jan 23:30

Choose a tag to compare

Version 1.3.1

Release 1.3.0

19 Jan 02:24
49627d8

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: https://github.com/albertalef/rubyshell/commits/v1.3.0