infrablocks / lino Goto Github PK
View Code? Open in Web Editor NEWCommand line builder and execution utilities.
License: MIT License
Command line builder and execution utilities.
License: MIT License
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
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
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.