Coder Social home page Coder Social logo

Comments (8)

DannyBen avatar DannyBen commented on June 22, 2024 1

Well - it is nice to see that bashly is easy enough to use that you have built (or planning to build) such a large bash script with it.

There is a command.filename option which lets you specify the path (in src) for each command. Isn't this sufficient?

See:


But now that I look a all this, I agree - it is tedious, and I am not a big fan of the fact that so many filenames end with *_command.sh.

I am going to try to do the following:

Have a setting in the settings.yml to say something like command_paths: nested that will set the path of a command docker status to src/commands/docker/status.sh instead of src/docker_status_command.sh

Makes sense?

from bashly.

n-rodriguez avatar n-rodriguez commented on June 22, 2024 1

It is beautiful right?

It is 👍 ❤️

from bashly.

DannyBen avatar DannyBen commented on June 22, 2024 1

Released in 1.0.7
Docs: https://bashly.dannyb.co/usage/settings/#commands_dir

This was a nice one Nicolas, thanks.

from bashly.

iamjackg avatar iamjackg commented on June 22, 2024 1

We've indeed been doing this manually the whole time for our (also pretty large) script :) Thanks for adding this!

from bashly.

n-rodriguez avatar n-rodriguez commented on June 22, 2024

Have a setting in the settings.yml to say something like command_paths: nested that will set the path of a command docker status to src/commands/docker/status.sh instead of src/docker_status_command.sh

Makes sense?

Sure!

But I don't know how your last PR will solve this issue? #399

from bashly.

DannyBen avatar DannyBen commented on June 22, 2024

The PR adds a setting value, that when set, will automatically organize all the commands in the src folder, in subdirectories.

See this example.

Points of interest:

# The path to use for command files, relative to source_dir
# When set to nil (~), command files will be placed directly under source_dir
# When set to any other string, command files will be placed under this
# directory, and each command will get its own subdirectory
# commands_dir: ~
commands_dir: commands

https://github.com/DannyBen/bashly/tree/master/examples/command-paths/src/commands

And, if you have sub-sub-commands - like cli docker image ls, its file will be src/commands/docker/image/ls.sh

Meaning: The setting not only sets a sub directory for commands, but it also changes the entire path generation logic.

Isn't this what you wanted?

You can use the edge version to test it.

from bashly.

n-rodriguez avatar n-rodriguez commented on June 22, 2024

You can use the edge version to test it.

I did with

# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }

gem 'bashly', github: 'DannyBen/bashly'

It works :)

├── commands
│   ├── completions.sh
│   ├── concerto
│   │   ├── config_dump.sh
│   │   ├── config_print.sh
│   │   ├── notify_release.sh
│   │   ├── notify_sentry.sh
│   │   ├── restart.sh
│   │   ├── setup.sh
│   │   ├── update_french_logo.sh
│   │   └── update_staging.sh
│   ├── docker
│   │   ├── config.sh
│   │   ├── down.sh
│   │   ├── enter.sh
│   │   ├── exec.sh
│   │   ├── images.sh
│   │   ├── logs.sh
│   │   ├── prune_images.sh
│   │   ├── ps.sh
│   │   ├── pull.sh
│   │   ├── restart.sh
│   │   ├── start.sh
│   │   ├── stop.sh
│   │   ├── top.sh
│   │   └── up.sh
│   ├── get-config
│   │   ├── concerto-version.sh
│   │   ├── date.sh
│   │   ├── debian-version.sh
│   │   ├── env.sh
│   │   ├── local.sh
│   │   └── service-version.sh
│   ├── maintenance
│   │   ├── start.sh
│   │   ├── status.sh
│   │   └── stop.sh
│   ├── postgres
│   │   ├── backup.sh
│   │   ├── psql.sh
│   │   ├── reindex.sh
│   │   ├── restore.sh
│   │   └── vacuum.sh
│   ├── rails
│   │   ├── console.sh
│   │   └── rake.sh
│   └── redis
│       └── cli.sh

At first I was surprised by the commands dir but it's consistent with the lib dir sitting next to it.

Thank you! It works great!

from bashly.

DannyBen avatar DannyBen commented on June 22, 2024

It is beautiful right? Much better for large scripts.

Thanks for suggesting it. I am updating the example so it is clearer that commands get subdirectories as well.

from bashly.

Related Issues (20)

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.