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

mdbook init force flag documentation is wrong #1556

Closed
joshrotenberg opened this issue May 30, 2021 · 9 comments · Fixed by #2057
Closed

mdbook init force flag documentation is wrong #1556

joshrotenberg opened this issue May 30, 2021 · 9 comments · Fixed by #2057
Assignees
Labels
A-CLI Area: CLI E-Help-wanted Experience: Help Needed

Comments

@joshrotenberg
Copy link
Contributor

joshrotenberg commented May 30, 2021

The documentation for the force flag for the init subcommand states "Skips confirmation prompts", but it actually only affects whether a prompt is given if the --theme flag is present and the theme directory exists. It has no effect on the prompts for creating the .gitignore or getting the book name (which, ok, isn't technically a "confirmation" prompt).

The easiest fix is to just update the documentation. Another fix might be to make the .gitignore prompt also respect the flag so that the "confirmation" part is technically right. It might also be helpful to add a flag for creating the .gitignore and the book title too to round things out and make book initialization fully prompt free if someone desires.

Something like this. If --force is specified, in addition to the current behavior, init the book with the defaults for --with-gitignore and --with-title.

mdbook-init v0.4.8
Creates the boilerplate structure and files for a new book

USAGE:
    mdbook init [FLAGS] [dir]

FLAGS:
        --force             Skips confirmation prompts
    -h, --help              Prints help information
        --theme             Copies the default theme into your source folder
    -V, --version           Prints version information
        --with-gitignore    Creates a .gitignore file [default: true]
        --with-title        Set the book title [default: "my book"]

ARGS:
    <dir>    Directory to create the book in
             (Defaults to the Current Directory when omitted)
@ehuss
Copy link
Contributor

ehuss commented May 31, 2021

Hm, looks like this was changed as part of #491, but there doesn't seem to be an explanation why. I would say the original intent is that it avoids all prompts. I agree that --force should probably not do any prompts.

@joshrotenberg
Copy link
Contributor Author

Thoughts on adding the extra flags as well to make it possible to supply an answer for book name and .gitignore creation as part of the fix here? Or do you prefer to just make force do what it says and use defaults for those (and maybe call them out in the documentation string)?

@ehuss
Copy link
Contributor

ehuss commented May 31, 2021

Preferably have separate PRs.

As for the flags, how about --title=... and --ignore=git or --ignore=none?

@joshrotenberg
Copy link
Contributor Author

As for the flags, how about --title=... and --ignore=git or --ignore=none?

I went with --gitignore as a boolean. If we wanted to support other .ignore file types, though, --ignore=<type> is probably better ... but the only other one I know is .hgignore.

The next step would be to set defaults and check --force first for both args:

  • if --force, set default
  • if is_present, set from command line value
  • otherwise prompt

@ehuss ehuss added A-CLI Area: CLI E-Help-wanted Experience: Help Needed labels Jul 6, 2021
@ISSOtm
Copy link
Contributor

ISSOtm commented Jun 18, 2022

What's the status on this?

@seanpoulter
Copy link
Contributor

I just found this issue. Would you welcome a PR? What default would you want for the title, Example book like the docs?

@seanpoulter
Copy link
Contributor

@rustbot claim

@ehuss
Copy link
Contributor

ehuss commented Mar 26, 2023

I'm not certain about the defaults, but I'll suggest:

  • Assume --ignore=none
  • Set BookConfig.title to None (no title)

@seanpoulter
Copy link
Contributor

Thanks @ehuss. I've got a PR #2057 up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI E-Help-wanted Experience: Help Needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants