Giter Club home page Giter Club logo

hedgehog's People

Contributors

brynbayliss87 avatar dan2552 avatar ridersargent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hedgehog's Issues

Crashes entire process if error in method within `.hedgehog`

What happens

Crashes out of process.

What went wrong

> cd /
Traceback (most recent call last):
	5: from app/app.rb:39:in `<main>'
	4: from /Users/dan2552/.gem/ruby/2.5.1/gems/bundler-1.16.3/lib/bundler.rb:543:in `with_env'
	3: from app/app.rb:46:in `block in <main>'
	2: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/input.rb:6:in `await_user_input'
	1: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/input.rb:23:in `get_prompt'
/Users/dan2552/.hedgehog:64:in `block in <top (required)>': undefined method `magenta' for nil:NilClass (NoMethodError)

undefined method `terminal_did_resize' for nil:NilClass

Traceback (most recent call last):
	12: from /Users/dan2552/Dropbox/Hedgehog/bin/../app/app.rb:40:in `<main>'
	11: from /Users/dan2552/.rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler.rb:562:in `with_env'
	10: from /Users/dan2552/Dropbox/Hedgehog/bin/../app/app.rb:49:in `block in <main>'
	 9: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/input/loop.rb:5:in `await_user_input'
	 8: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/input/loop.rb:5:in `loop'
	 7: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/input/loop.rb:11:in `block in await_user_input'
	 6: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/runner.rb:14:in `run'
	 5: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/runner.rb:14:in `each'
	 4: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/runner.rb:16:in `block in run'
	 3: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/binary.rb:11:in `run'
	 2: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/binary.rb:11:in `wait'
	 1: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/binary.rb:11:in `call'
/Users/dan2552/Dropbox/Hedgehog/app/hedgehog/input/line_editor.rb:49:in `size_changed': undefined method `terminal_did_resize' for nil:NilClass (NoMethodError)

bin/hedgehog assumes chruby is installed

Running bin/hedgehog causes:

bin/hedgehog: line 7: /usr/local/share/chruby/chruby.sh: No such file or directory
bin/hedgehog: line 8: chruby: command not found

bin/hedgehog should probably somehow be agnostic to how you install ruby?

chruby support

I think it would make sense to release chruby support either as a separate gem or at least something that can be optionally required in the .hedgehog file.

In the meantime, putting the following straight in .hedgehog should work:

original_cd = function "cd"
function "cd" do |args|
  original_cd.call(args)
  break unless File.exists?(".ruby-version")
  function("chruby").call(Hedgehog::Command::Arguments.new(`cat .ruby-version`.chomp))
end

function "chruby" do |args|
  output = `bash -lc "source /usr/local/share/chruby/chruby.sh; chruby #{args}; echo "§chruby-environment§"; ENV"`
  out, env_str = output.split("§chruby-environment§\n")

  print out

  break unless args.count > 0

  env_vars = env_str.split("\n").map { |env| env.split("=") }

  env_vars.each do |env_var|
    variable, value = env_var
    next unless ["PATH", "RUBY_ROOT", "GEM_HOME", "GEM_ROOT", "GEM_PATH"].include? variable
    ENV[variable] = value
  end
end

Buffered input

type sleep 10\necho hello

should execute echo hello after finishing execution of sleep 10

Spawning binary that doesn't exist

What happens

Crashes out of process.

What went wrong

Typed bundle where ruby was set to system ruby, where no bundler was installed.

Traceback (most recent call last):
	9: from app/app.rb:39:in `<main>'
	8: from /Users/dan2552/.gem/ruby/2.5.1/gems/bundler-1.16.3/lib/bundler.rb:543:in `with_env'
	7: from app/app.rb:46:in `block in <main>'
	6: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/input.rb:11:in `await_user_input'
	5: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/runner.rb:10:in `run'
	4: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/runner.rb:19:in `execute_command'
	3: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/runner.rb:19:in `each'
	2: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/runner.rb:21:in `block in execute_command'
	1: from /Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/binary.rb:10:in `run'
/Users/dan2552/Dropbox/Hedgehog/app/hedgehog/execution/binary.rb:10:in `spawn': No such file or directory - /usr/local/bin/bundle (_Errno::ENOENT_)

multiline bash commands

awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
    s="/\\";
    for (colnum = 0; colnum<term_cols; colnum++) {
        r = 255-(colnum*255/term_cols);
        g = (colnum*510/term_cols);
        b = (colnum*255/term_cols);
        if (g>255) g = 510-g;
        printf "\033[48;2;%d;%d;%dm", r,g,b;
        printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
        printf "%s\033[0m", substr(s,colnum%2+1,1);
    }
    printf "\n";
}'

Supporting $?

e.g. correctly handling

echo "hello" | grep b
echo $?

echo "hello" | grep b
$?

Specs

The project needs specs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.