Skip to content

Commit

Permalink
Converted to package
Browse files Browse the repository at this point in the history
  • Loading branch information
sellorm committed Mar 18, 2023
1 parent fb96c34 commit c7eff18
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2023 Mark Sellors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
all: README.md

README.md: README.bashdown bashdown
./bashdown README.bashdown > README.md
bashdown README.bashdown > README.md
4 changes: 2 additions & 2 deletions README.bashdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ significantly fewer dependencies due to it's much more limited scope.
Basic usage is as follows:

```bash
# ./bashdown README.bashdown > README.md
# bashdown README.bashdown > README.md
```

Full usage information can be obtained from the built in help.

```bash
./bashdown --help
bashdown --help
```


Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ significantly fewer dependencies due to it's much more limited scope.
Basic usage is as follows:

```bash
# ./bashdown README.bashdown > README.md
# bashdown README.bashdown > README.md
```

Full usage information can be obtained from the built in help.

```bash
./bashdown --help
bashdown --help
```

```output
Expand All @@ -41,7 +41,7 @@ Processes in-line bash in markdown files
positional arguments:
filename
optional arguments:
options:
-h, --help show this help message and exit
For more information please see the docs
Expand Down
16 changes: 12 additions & 4 deletions bashdown → bashdown/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""
Takes a markdown file with bash code blocks, executes the bash commands and
returns the original markdown content with output blocks containing the
Expand All @@ -8,6 +7,7 @@
import argparse
import re
import subprocess
import sys


def process_content(input_lines):
Expand Down Expand Up @@ -42,16 +42,24 @@ def process_content(input_lines):
print(line, end="")


if __name__ == "__main__":
def cli_arg_parser(args=None):
parser = argparse.ArgumentParser(
prog="bashdown",
description="Processes in-line bash in markdown files",
epilog="For more information please see the docs",
)
parser.add_argument("filename")
args = parser.parse_args()
return parser.parse_args()


def main():
args = cli_arg_parser(sys.argv[1:])

with open(args.filename, "r") as file:
with open(args.filename, "r", encoding="utf8") as file:
content = file.readlines()

process_content(content)


if __name__ == "__main__":
main()
Binary file added bashdown/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
7 changes: 7 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.poetry]
name = "bashdown"
version = "0.1.0"
description = "Executes in-line bash in markdown files"
authors = ["Mark Sellors <[email protected]>"]
readme = "README.md"
repository = "https://github.com/python-poetry/poetry"
homepage = "https://python-poetry.org/"


[tool.poetry.dependencies]
python = "^3.10"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
bashdown = "bashdown:main"

0 comments on commit c7eff18

Please sign in to comment.