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

Running command in a directory #75

Open
bhargavrpatel opened this issue Jun 4, 2023 · 0 comments
Open

Running command in a directory #75

bhargavrpatel opened this issue Jun 4, 2023 · 0 comments

Comments

@bhargavrpatel
Copy link

bhargavrpatel commented Jun 4, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant