Skip to content

Commit

Permalink
0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
a committed Nov 5, 2020
1 parent fdcea8a commit 2055d4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ hist-md # Markdown format shortcut
hist-txt # Text format shortcut
```
```
usage: hist-format [-h] [-f FORMAT] [-c COUNT] [-cmd] [-l]
usage: hist-format [-h] [-f FORMAT] [-c COUNT] [-l] [--lines]
Format xonsh history to post it to Github or another page.
Expand All @@ -35,9 +35,9 @@ optional arguments:
Format: md, txt.
-c COUNT, --count COUNT
Count of commands
-cmd, --show-commands
-l, --show-commands-list
Show commands in distinct section.
-l, --lines Add additional lines before and after.
--lines Add additional lines before and after.
```

## Example
Expand All @@ -48,13 +48,13 @@ ls / | head -n 3
```
Run hist-format:
```python
hist-md -c 2 -l # latest 2 commands with header and footer as line
hist-md -c 2 -l --lines # latest 2 commands + commands list + header and footer as line
```
As result you will get the output that you can copy and paste to the Github comment or md-file:

------------------------------------------------------------------------------------------------------------------

<sub>[hist-format](https://github.com/anki-code/xontrib-hist-format) output:</sub>
Output:

```python
echo 123
Expand All @@ -65,13 +65,16 @@ ls / | head -n 3
#cdrom
#dev

# Prepared by xontrib-hist-format
```

<sub>[hist-format](https://github.com/anki-code/xontrib-hist-format) commands:</sub>
Commands:

```python
echo 123
ls / | head -n 3

# Prepared by xontrib-hist-format
```

------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions xontrib/hist_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ def _hist_format(args):
argp = argparse.ArgumentParser(prog='hist-format', description="Format xonsh history to post it to Github or another page.")
argp.add_argument('-f', '--format', default='md', help="Format: md, txt.")
argp.add_argument('-c', '--count', default=10, help="Count of commands")
argp.add_argument('-cmd', '--show-commands', action='store_true', help="Show commands in distinct section.")
argp.add_argument('-l', '--lines', action='store_true', help="Add additional lines before and after.")
argp.add_argument('-l', '--show-commands-list', action='store_true', help="Show commands in distinct section.")
argp.add_argument('--lines', action='store_true', help="Add additional lines before and after.")
opt = argp.parse_args(args)

opt.count = int(opt.count)
Expand Down Expand Up @@ -54,7 +54,7 @@ def _hist_format(args):
print(format['comment'] + ' Prepared by xontrib-hist-format')
print(format['end'])

if opt.show_commands:
if opt.show_commands_list:
if opt.format == 'md':
print('\nCommands:\n')
else:
Expand Down

0 comments on commit 2055d4e

Please sign in to comment.