GithubHelp home page GithubHelp logo

infrablocks / lino Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 1.0 281 KB

Command line builder and execution utilities.

License: MIT License

Ruby 92.95% Shell 7.05%
ruby gem command-line command rubygem ruby-library ruby-gem builder commandline infrablocks

lino's People

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

sa73917

lino's Issues

Running command in a directory

Hi folks -- Really loving Lino so far. It makes removes string interpolation to run hacky commands. What is the recommended approach in running a command (or a set of commands) in a given directory. Below is an example of set of bash commands I currently run either using system(command) or RubyExpect::Expect.spawn(command)

path = '/somewhere/i/belong`
shell_command = <<-HEREDOC
  (
    cd #{path} && \
    git clean -fdx && \
    git reset --hard && \
    git fetch origin master && \
    git checkout master && \
    git pull --rebase
  )
HEREDOC

RubyExpect::Expect.spawn(command).interact

I am not entirely sure how I should approach this with Lino which allows me to iteratively build essentially the command I would run in bash. How should I run git clean -fdx in a given directory? I am currently doing what is below but I think it takes away from the overall iterative building experience.

Lino::CommandLineBuilder
  .for_command("git")
  .with_subcommand('clean') { |s| s.with_flag('-fdx') }
  .build
  .to_s
# => "cd /somewhere/i/belong && git clean -fdx"

Am I missing something from the DSL I could use? If there is no clean way to do this, it might be helpful to have something along the lines of:

# Hypothetical proposal
Lino::CommandLineBuilder
  .for_command("git")
  .with_subcommand('clean') { |s| s.with_flag('-fdx') }
  .in_directory(repo_dir) # new
  .build

Feature request: Support subcommands with arguments

Currently,

command = Lino::CommandLineBuilder
    .for_command('x')
    .with_subcommand('y') do |sub|
      sub.with_argument('fake_argument')
    end

results in

undefined method `with_argument' for #<Lino::SubcommandBuilder:0x00007f8b8289b268> (NoMethodError)

Would it be possible to add support for with_argument in SubcommandBuilder?

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.