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

feature: expose --help from rails #8

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

onshi
Copy link
Contributor

@onshi onshi commented Mar 27, 2024

This PR allows to expose rails new --help output as a subcommand for rails-new

closes #7

./target/debug/rails-new help

A CLI tool to generate a new Rails project

Usage: rails-new [OPTIONS] <ARGS>...
       rails-new [OPTIONS] [ARGS]... <COMMAND>

Commands:
  rails-help  Prints `rails --help`
  help        Print this message or the help of the given subcommand(s)

Arguments:
  <ARGS>...  arguments passed to `rails new`

Options:
  -u, --ruby-version <RUBY_VERSION>    [default: 3.2.3]
  -r, --rails-version <RAILS_VERSION>  [default: 7.1.3]
  -h, --help                           Print help
  -V, --version                        Print version

./target/debug/rails-new rails-help

Usage:
  rails new APP_PATH [options]

Options:
                 [--skip-namespace]                             # Skip namespace (affects only isolated engines)
                                                                # Default: false
                 [--skip-collision-check]                       # Skip collision check
                                                                # Default: false
  -r,            [--ruby=PATH]                                  # Path to the Ruby binary of your choice
                                                                # Default: /usr/local/bin/ruby
  -n,            [--name=NAME]                                  # Name of the app
  -m,            [--template=TEMPLATE]                          # Path to some application template (can be a filesystem path or URL)
  -d,            [--database=DATABASE]                          # Preconfigure for selected database (options: mysql/trilogy/postgresql/sqlite3/oracle/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                                                # Default: sqlite3
  -G,            [--skip-git]                                   # Skip git init, .gitignore and .gitattributes
                 [--skip-docker]                                # Skip Dockerfile, .dockerignore and bin/docker-entrypoint
                 [--skip-keeps]                                 # Skip source control .keep files
  -M,            [--skip-action-mailer]                         # Skip Action Mailer files
                 [--skip-action-mailbox]                        # Skip Action Mailbox gem
                 [--skip-action-text]                           # Skip Action Text gem
  -O,            [--skip-active-record]                         # Skip Active Record files
                 [--skip-active-job]                            # Skip Active Job
                 [--skip-active-storage]                        # Skip Active Storage files
  -C,            [--skip-action-cable]                          # Skip Action Cable files
  -A,            [--skip-asset-pipeline]                        # Indicates when to generate skip asset pipeline
  -a,            [--asset-pipeline=ASSET_PIPELINE]              # Choose your asset pipeline [options: sprockets (default), propshaft]
                                                                # Default: sprockets
  -J, --skip-js, [--skip-javascript]                            # Skip JavaScript files
                 [--skip-hotwire]                               # Skip Hotwire integration
                 [--skip-jbuilder]                              # Skip jbuilder gem
  -T,            [--skip-test]                                  # Skip test files
                 [--skip-system-test]                           # Skip system test files
                 [--skip-bootsnap]                              # Skip bootsnap gem
                 [--skip-dev-gems]                              # Skip development gems (e.g., web-console)
                 [--dev], [--no-dev], [--skip-dev]              # Set up the application with Gemfile pointing to your Rails checkout
                 [--edge], [--no-edge], [--skip-edge]           # Set up the application with a Gemfile pointing to the 7-1-stable branch on the Rails repository
  --master,      [--main], [--no-main], [--skip-main]           # Set up the application with Gemfile pointing to Rails repository main branch
                 [--rc=RC]                                      # Path to file containing extra configuration options for rails command
                 [--no-rc]                                      # Skip loading of extra configuration options from .railsrc file
                 [--api], [--no-api], [--skip-api]              # Preconfigure smaller stack for API only apps
                                                                # Default: false
                 [--minimal], [--no-minimal], [--skip-minimal]  # Preconfigure a minimal rails app
  -j, --js,      [--javascript=JAVASCRIPT]                      # Choose JavaScript approach [options: importmap (default), bun, webpack, esbuild, rollup]
                                                                # Default: importmap
  -c,            [--css=CSS]                                    # Choose CSS processor [options: tailwind, bootstrap, bulma, postcss, sass] check https://github.com/rails/cssbundling-rails for more options
  -B,            [--skip-bundle]                                # Don't run bundle install
                 [--skip-decrypted-diffs]                       # Don't configure git to show decrypted diffs of encrypted credentials

Runtime options:
  -f, [--force]                                      # Overwrite files that already exist
  -p, [--pretend], [--no-pretend], [--skip-pretend]  # Run but do not make any changes
  -q, [--quiet], [--no-quiet], [--skip-quiet]        # Suppress status output
  -s, [--skip], [--no-skip], [--skip-skip]           # Skip files that already exist

Rails options:
  -h, [--help], [--no-help], [--skip-help]           # Show this help message and quit
  -v, [--version], [--no-version], [--skip-version]  # Show Rails version number and quit

Description:
    The `rails new` command creates a new Rails application with a default
    directory structure and configuration at the path you specify.

    You can specify extra command-line arguments to be used every time
    `rails new` runs in the .railsrc configuration file in your home directory,
    or in $XDG_CONFIG_HOME/rails/railsrc if XDG_CONFIG_HOME is set.

    Note that the arguments specified in the .railsrc file don't affect the
    default values shown above in this help message.

    You can specify which version to use when creating a new rails application 
    using `rails _<version>_ new`.

Examples:
    `rails new ~/Code/Ruby/weblog`

    This generates a new Rails app in ~/Code/Ruby/weblog.

    `rails _<version>_ new weblog`

    This generates a new Rails app with the provided version in ./weblog.

    `rails new weblog --api`

    This generates a new Rails app in API mode in ./weblog.

    `rails new weblog --skip-action-mailer`

    This generates a new Rails app without Action Mailer in ./weblog.
    Any part of Rails can be skipped during app generation.

@onshi onshi force-pushed the feature/expose_help_from_rails branch 3 times, most recently from 9fb6637 to a1402b8 Compare March 27, 2024 02:10
@onshi onshi marked this pull request as ready for review March 27, 2024 02:16
@onshi onshi force-pushed the feature/expose_help_from_rails branch 2 times, most recently from 71f58d1 to 3a3efb5 Compare March 27, 2024 02:29
@@ -10,6 +10,15 @@ pub struct Cli {
pub ruby_version: String,
#[clap(long, short = 'r', default_value = "7.1.3")]
pub rails_version: String,

#[command(subcommand)]
pub command: Option<Commands>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write a test for this?

src/main.rs Outdated
assert!(status.success());
match &cli.command {
Some(Commands::RailsHelp {}) => {
let mut child = DockerClient::get_help(&ruby_version, &rails_version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use subprocess here?

@rafaelfranca rafaelfranca force-pushed the feature/expose_help_from_rails branch from a3f7fe1 to 9e1a697 Compare March 28, 2024 20:25
@rafaelfranca rafaelfranca force-pushed the feature/expose_help_from_rails branch from 9e1a697 to 6b9fddd Compare March 28, 2024 20:27
@rafaelfranca rafaelfranca merged commit 8235904 into rails:main Mar 28, 2024
3 checks passed
@onshi
Copy link
Contributor Author

onshi commented Mar 28, 2024

thanks for wrapping it up 🙇🏻

@onshi onshi deleted the feature/expose_help_from_rails branch March 28, 2024 21:23
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

Successfully merging this pull request may close these issues.

Expose --help from the Rails command
2 participants