Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ cli
.option('--port <port>', `[number] specify port`)
.option('--https', `[boolean] use TLS + HTTP/2`)
.option('--open [path]', `[boolean | string] open browser on startup`)
.option('--no-open', `[boolean] prevents browser opening on startup`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So as you already found out, this is invalid due to cac provide this by default

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I unfortunately don't see an option in cac to provide any kind of global option aside text for all options. There are a couple methods like usage, example, or command description I could leverage but the output isn't the greatest and doesn't seem fit for this use case.

I could use example and show one usage of using the negation option feature of cac?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah oh, so this theoretically overrides just the description text?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe this is something you could discuss in an issue or discussion in cac @drobannx , maybe they have best practices already

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, the change in this PR would only show that additional option but cac does treat the defaults differently in this case.

https://github.com/cacjs/cac#negated-options

So this change would set open to true by default but then passing --no-open as an arg would set the value to false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you got it yourself, but just want to mention it: changing the default value is not an option
The default have to be false in this case

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@matias-capeletto - I'll go ahead and close this PR and see if there is some discussion over in cac about this. Thank you and @Shinigami92 for your time in helping with this, I appreciate it!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Looks like there already is an open PR over there for this very issue: cacjs/cac#104

.option('--cors', `[boolean] enable CORS`)
.option('--strictPort', `[boolean] exit if specified port is already in use`)
.option('-m, --mode <mode>', `[string] set env mode`)
Expand Down