-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Made output docopt compatible #13220
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4daf2c0
Added addUsage() to specify usage patterns
wouterj 43c1c85
Made output docopt compatible
wouterj d462aba
Customize usage section
wouterj d9a42c9
Fixed some more tests
wouterj 749d9cf
Added test for multiline descriptions
wouterj 7489720
Made fabbot happy
wouterj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added test for multiline descriptions
- Loading branch information
commit 749d9cfba65fdcf81301473200f7f55b7f724e31
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,8 @@ protected function describeInputArgument(InputArgument $argument, array $options | |
$this->writeText(sprintf(" <info>%s</info>%s%s%s", | ||
$argument->getName(), | ||
str_repeat(' ', $spacingWidth), | ||
str_replace("\n", "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()), | ||
// + 17 = 2 spaces + <info> + </info> + 2 spaces | ||
preg_replace('/\s*\R\s*/', PHP_EOL.str_repeat(' ', $totalWidth + 17), $argument->getDescription()), | ||
$default | ||
), $options); | ||
} | ||
|
@@ -79,7 +80,8 @@ protected function describeInputOption(InputOption $option, array $options = arr | |
$this->writeText(sprintf(" <info>%s</info>%s%s%s%s", | ||
$synopsis, | ||
str_repeat(' ', $spacingWidth), | ||
str_replace("\n", "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()), | ||
// + 17 = 2 spaces + <info> + </info> + 2 spaces | ||
preg_replace('/\s*\R\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The additional lines only need to have +4 spaces as the |
||
$default, | ||
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : '' | ||
), $options); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Symfony/Component/Console/Tests/Fixtures/input_argument_4.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"argument_name","is_required":true,"is_array":false,"description":"multiline argument description","default":null} |
8 changes: 8 additions & 0 deletions
8
src/Symfony/Component/Console/Tests/Fixtures/input_argument_4.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
**argument_name:** | ||
|
||
* Name: argument_name | ||
* Is required: yes | ||
* Is array: no | ||
* Description: multiline | ||
argument description | ||
* Default: `NULL` |
2 changes: 2 additions & 0 deletions
2
src/Symfony/Component/Console/Tests/Fixtures/input_argument_4.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<info>argument_name</info> multiline | ||
argument description |
6 changes: 6 additions & 0 deletions
6
src/Symfony/Component/Console/Tests/Fixtures/input_argument_4.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<argument name="argument_name" is_required="1" is_array="0"> | ||
<description>multiline | ||
argument description</description> | ||
<defaults/> | ||
</argument> |
1 change: 1 addition & 0 deletions
1
src/Symfony/Component/Console/Tests/Fixtures/input_option_5.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"--option_name","shortcut":"-o","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"multiline option description","default":null} |
10 changes: 10 additions & 0 deletions
10
src/Symfony/Component/Console/Tests/Fixtures/input_option_5.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**option_name:** | ||
|
||
* Name: `--option_name` | ||
* Shortcut: `-o` | ||
* Accept value: yes | ||
* Is value required: yes | ||
* Is multiple: no | ||
* Description: multiline | ||
option description | ||
* Default: `NULL` |
2 changes: 2 additions & 0 deletions
2
src/Symfony/Component/Console/Tests/Fixtures/input_option_5.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<info>-o, --option_name=OPTION_NAME</info> multiline | ||
option description |
6 changes: 6 additions & 0 deletions
6
src/Symfony/Component/Console/Tests/Fixtures/input_option_5.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<option name="--option_name" shortcut="-o" accept_value="1" is_value_required="1" is_multiple="0"> | ||
<description>multiline | ||
option description</description> | ||
<defaults/> | ||
</option> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The additional lines only need to have +4 spaces as the
<info></info>
elements only apply to the first line and that's catered for in the sprintf.