Repository: StackStorm/st2

Issue:
Column width increase
Minor issue, but with the default column width set to 28, I'm seeing output like this:

```
# st2 execution list --action cybera.hello
+--------------------------+--------------+--------------+-----------+------------------------------+------------------------------+
| id                       | action.ref   | context.user | status    | start_timestamp              | end_timestamp                |
+--------------------------+--------------+--------------+-----------+------------------------------+------------------------------+
| 54eb49e8bda19059c109d178 | cybera.hello | stanley      | succeeded | Mon, 23 Feb 2015 15:40:24    | Mon, 23 Feb 2015 15:40:24    |
|                          |              |              |           | UTC                          | UTC                          |
+--------------------------+--------------+--------------+-----------+------------------------------+------------------------------+
```

Bumping it up to 29 (or higher) returns the expected format:

```
# st2 execution list --action cybera.hello
+--------------------------+--------------+--------------+-----------+-------------------------------+-------------------------------+
| id                       | action.ref   | context.user | status    | start_timestamp               | end_timestamp                 |
+--------------------------+--------------+--------------+-----------+-------------------------------+-------------------------------+
| 54eb49e8bda19059c109d178 | cybera.hello | stanley      | succeeded | Mon, 23 Feb 2015 15:40:24 UTC | Mon, 23 Feb 2015 15:40:24 UTC |
+--------------------------+--------------+--------------+-----------+-------------------------------+-------------------------------+
```



Discussion:
We need a rc file for CLI so some of these can be configured there. Thanks for the bug report.

Opened https://stackstorm.atlassian.net/browse/STORM-1061 to track report.

@jtopjian This is actually a feature right now - we set the default number of columns based on the terminal size (width).

If there is more text it will be wrapped across multiple lines. I think defaulting to the terminal width is quite reasonable since horizontal scrolling is usually very annoying. And different actions and responses produce different number of columns so the response will always wrap unless we set the column number to a very large number, but this will result in a huge and annoying horizontal scrollbar.

And if you want raw output, the default user-friendly format is not the best choice and you should use something like json (-j flag).

@Kami OK, that's good to know about the terminal width. That might be the underlying issue at hand: my terminal was actually 2-3x wider than the wrapped table I pasted. I dug into the st2client code a bit and saw that the width of each column had a max limit of 28, which is where the wrapping was coming into play.

Maybe the full width of the terminal isn't being read correctly? I know that can be an issue caused by ssh sessions, terminal applications, etc.

I'd be happy to report any terminal settings from my side if it would help.

@jtopjian Hm, thanks, this might indeed be a bug then - will look into it tomorrow.

Also, just to confirm, the terminal was bigger than the table before you ran the command?

@Kami Yes, the terminal was at its max width prior to me running the command :)

Let me know if I can provide any more info.

@jtopjian Alright thanks - I think I should have enough info for now. Will keep you posted when I figure out the root cause and if I need more info :)


Resolving patch:
diff --git a/st2client/st2client/commands/action.py b/st2client/st2client/commands/action.py
--- a/st2client/st2client/commands/action.py
+++ b/st2client/st2client/commands/action.py
@@ -570,7 +570,7 @@ def __init__(self, resource, *args, **kwargs):
                                        'output. "all" will return all '
                                        'attributes.'))
         self.parser.add_argument('-w', '--width', nargs='+', type=int,
-                                 default=[28],
+                                 default=None,
                                  help=('Set the width of columns in output.'))
 
     @add_auth_token_to_kwargs_from_cli
@@ -619,7 +619,7 @@ def __init__(self, resource, *args, **kwargs):
 
         root_arg_grp = self.parser.add_mutually_exclusive_group()
 
-        #
+        # Filtering options
         task_list_arg_grp = root_arg_grp.add_argument_group()
         task_list_arg_grp.add_argument('--tasks', action='store_true',
                                        help='Whether to show sub-tasks of an execution.')
@@ -629,7 +629,7 @@ def __init__(self, resource, *args, **kwargs):
         task_list_arg_grp.add_argument('-w', '--width', nargs='+', type=int, default=[28],
                                        help='Set the width of columns in output.')
 
-        #
+        # Display options
         execution_details_arg_grp = root_arg_grp.add_mutually_exclusive_group()
 
         detail_arg_grp = execution_details_arg_grp.add_mutually_exclusive_group()


Test patch: