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

Require a local run.rb file on ruby -run #3771

Closed
wants to merge 1 commit into from
Closed

Require a local run.rb file on ruby -run #3771

wants to merge 1 commit into from

Conversation

sdwolfz
Copy link

@sdwolfz sdwolfz commented Nov 16, 2020

Crazy idea, I know, but hear me out!

This is to allow more functinality to be built on top of what lib/un.rb
provides. With this change you can have a run.rb file locally with
arbitrary ruby code...

puts 'Hello!'

...which will be executed when you do ruby -run from that directory.

You should aslo be able to execut functions...

def greet
  puts 'Hello!'
end

...using the -e flag: ruby -run -e greet

Best of all, you can reuse the setup provided in un.rb to handle
extra flags:

def greet
  setup('w') do |argv, options|
    puts "Hello #{argv[0]}"
  end
end

...which gets executed with: ruby -run -e greet -- -w World

The possibilities are endless!

Crazy idea, I know, but hear me out!

This is to allow more functinality to be built on top of what `lib/un.rb`
provides. With this change you can have a `run.rb` file locally with
arbitrary ruby code...

```ruby
puts 'Hello!'
```

...which will be executed when you do `ruby -run` from that directory.

You should aslo be able to execut functions...

```ruby
def greet
  puts 'Hello!'
end
```

...using the `-e` flag: `ruby -run -e greet`

Best of all, you can reuse the `setup` provided in `un.rb` to handle
extra flags:

```ruby
def greet
  setup('w') do |argv, options|
    puts "Hello #{argv[0]}"
  end
end
```

...which gets executed with: `ruby -run -e greet -- -w World`

The possibilities are endless!
@hsbt hsbt closed this Nov 17, 2020
@hsbt
Copy link
Member

hsbt commented Nov 17, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants