Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Request #16497 Cascade line width when using commands.
Submitted: 2009-08-07 21:01 UTC
From: rquadling Assigned: izi
Status: Closed Package: Console_CommandLine (version 1.1.0)
PHP Version: 5_3 CVS-2009-08-07 OS: Windows XP SP3
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 38 - 23 = ?

 
 [2009-08-07 21:01 UTC] rquadling (Richard Quadling)
Description: ------------ I use an ANSI terminal which allows me to have very wide console displays (200 characters wide). So I set the Renderer's Line width to 200. And I also have to set if for each command that I add (and sub command). I've attached the patch and a test script. Run the script as ... test.php -h test.php sub -h without and then with the patch. Only with the patch will test.php sub -h output be wrapped correctly. Expected result: ---------------- 1 3 5 7 9 12 15 18 21 24 27 30 33 36 39 41 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 103 107 111 115 119 123 127 131 135 139. Usage: Test_LongDescriptions.php [options] sub [options] Options: -h, --help show this help message and exit Actual result: -------------- 1 3 5 7 9 12 15 18 21 24 27 30 33 36 39 41 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 103 107 111 115 119 123 127 131 135 139. Usage: Test_LongDescriptions.php [options] sub [options] Options: -h, --help show this help message and exit

Comments

 [2009-08-07 21:01 UTC] rquadling (Richard Quadling)
The following patch has been added/updated: Patch Name: patch.diff Revision: 1249660916 URL: http://pear.php.net/bugs/patch-display.php?bug=16497&patch=patch.diff&revision=1249660916&display=1
 [2009-08-07 21:06 UTC] rquadling (Richard Quadling)
< ?php // Remove space from above line to get this to run. require_once 'Console/CommandLine.php'; $o_CommandParser = new Console_CommandLine( array( 'description' => '1 3 5 7 9 12 15 18 21 24 27 30 33 36 39 41 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 103 107 111 115.', 'name' => 'Test_LongDescriptions.php', 'version' => 'V1.00', ) ); $o_CommandParser->renderer->line_width = 40; $o_CommandParser->addOption( 'flag', array( 'action' => 'StoreTrue', 'description' => '1 3 5 7 9 12 15 18 21 24 27 30 33 36 39 41 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 103 107 111 115 119 123 127 131 135 139.', 'long_name' => '--dummy', 'short_name' => '-d', ) ); $o_CommandParser->addOption( 'another_flag', array( 'action' => 'StoreTrue', 'description' => '1 3 5 7 9 12 15 18 21 24 27 30 33 36 39 41 45 48 51 54 57.', 'long_name' => '--dummy2', 'short_name' => '-u', ) ); $o_CommandParserSubCommand = $o_CommandParser->addCommand( 'sub', array( 'description' => '1 3 5 7 9 12 15 18 21 24 27 30 33 36 39 41 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 103 107 111 115 119 123 127 131 135 139.', ) ); $o_CommandLine = $o_CommandParser->parse();
 [2009-08-18 16:51 UTC] izi (David Jean Louis)
Ah... good catch, but this is a bit more complicated, I think *all* parent settings should "cascade" in the subcommands if not explicitly given in the addCommand() method (I mean: renderer, outputter, message_provider etc...). I'll look at this. Thanks, -- David
 [2009-08-18 18:07 UTC] rquadling (Richard Quadling)
Yeah. I didn't have the time to work all that out. So you can keep this on the back burner until such time as you've sorted out how you want this to go.
 [2009-08-24 19:14 UTC] izi (David Jean Louis)
-Status: Open +Status: Closed -Assigned To: +Assigned To: izi
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Richard, I fixed this, can you review he fix and tell me if you see something I forgot ? thanks !
 [2009-08-24 19:32 UTC] rquadling (Richard Quadling)
Looks good. I would add a small note to the documentation though. My note relates only to my experience in testing this patch with the renderer->line_width setting. Setting the line with needs to be done before any sub commands are added. When a sub command is added it inherits a copy of the setting from the parent, but does not bind itself to the parent setting. Changes to the parent setting do not affect the setting in previously added sub-commands. Or words to that effect. I'm too wordy.
 [2009-08-24 19:47 UTC] izi (David Jean Louis)
No, you're right, that's perfect, I'll add it to the documentation. The problem is that I can't pass a reference to the renderer since it's tied to the Console_CommandLine instance...