Skip to content

Commit

Permalink
Updated the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dhondta committed Dec 15, 2020
1 parent 344acc0 commit d2d7d69
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
39 changes: 17 additions & 22 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
## Introduction

Tinyscript aims to quickly prototype scripts or tools by sparing as much lines of code as possible and providing base features (especially useful for debugging or understanding the execution flow) like configured logging, preimports, stepping, timing and so forth.
Tinyscript aims to quickly prototype tools by sparing as much lines of code as possible and providing base features (especially useful for debugging or understanding the execution flow) like configured logging, preimports, stepping, timing and so forth.

The idea is to make creating scripts/tools as easy as this:
The idea is to make creating tools as easy as this:

```sh
$ tinyscript-new script --name "my-script"
$ gedit my-script.py
$ tinyscript new test && gedit test.py
```

Simply modifying the template to:
Expand All @@ -16,6 +15,8 @@ Simply modifying the template to:
# -*- coding: UTF-8 -*-
from tinyscript import *

__author__ = "John Doe"
__version__ = "1.0"

if __name__ == '__main__':
parser.add_argument("string", help="string to be displayed")
Expand All @@ -26,19 +27,22 @@ if __name__ == '__main__':
Will give the following:

```sh
$ python script.py -h
usage: script [-h] [-v] string
$ python test.py --help
Test 1.0
Author : John Doe

Script
usage: python test.py [-h] [--help] [-v] string

positional arguments:
string string to be displayed
string string to be displayed

optional arguments:
-h, --help show this help message and exit
-v debug verbose level (default: false)

$ python script.py "Hello World!"
extra arguments:
-h show usage message and exit
--help show this help message and exit
-v, --verbose verbose mode (default: False)

$ python test.py "Hello World!"
01:02:03 [INFO] Hello World!
```

Expand All @@ -64,14 +68,5 @@ pip3 install --user tinyscript

This library is born from the need of quickly building efficient scripts and tools without caring for redefining various things or rewritting/setting the same functionalities like the logging or parsing of input arguments.

In the meantime, I personnally used this library many times to create scripts/tools for my job or during cybersecurity or programming competitions and it proved very useful when dealing with time constraints.

-----

## Definitions

In the remainder of this documentation, the following terms are used:

- **Script**: Simple code, as slight as possible, more suitable for a single or very specific use.
In the meantime, I personnally used this library many times to create tools for my job or during cybersecurity or programming competitions and it proved very useful when dealing with time constraints.

- **Tool**: More complete code, with metadata and comments, heavier than a *Script*, also aimed at being installed on a system.
44 changes: 25 additions & 19 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,53 @@ Some example script/tools are available on the [GitHub repo](https://github.com/

A tiny tool is provided with the package to create a template instantly.

- **Create a script**
- **Create a tool**

```sh
$ tinyscript-new script
$ tinyscript new test
```

This creates a script named `script.py` with minimal code.
This creates a script named `test.py` with minimal code.

??? example "`script.py`"
??? example "`test.py`"

:::python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from tinyscript import *
# TODO: fill in imports


__author__ = "John Doe"
__email__ = "john.doe@example.com"
__version__ = "1.0"
__copyright__ = "J. Doe"
__license__ = "agpl-3.0"
#__reference__ = ""
#__source__ = ""
#__training__ = ""
# TODO: fill in the docstring
__doc__ = """
This tool ...
"""
# TODO: fill in examples
__examples__ = [""]


if __name__ == '__main__':
parser.add_argument("", help="")
# TODO: write new arguments
# TODO: add arguments
initialize()
# TODO: use validate(...) if necessary
# TODO: write logic here

<br>

- **Create a tool**

```sh
$ tinyscript-new tool
```

This creates a script named `tool.py` with a bit more code, comments and placeholders.

- **Create a PyBot script/tool**
- **Create a PyBot tool**

```sh
$ tinyscript-new script pybots.HTTPBot --name my-http-bot
$ tinyscript-new tool pybots.JSONBot --name my-json-bot
$ tinyscript new test --target pybots.JSONBot
```

This creates a script/tool with a specific name and an import of particular class from the [PyBots library](https://github.com/dhondta/pybots).
This creates a tool with a specific name and an import of particular class from the [PyBots library](https://github.com/dhondta/python-pybots).


## Customization
Expand Down

0 comments on commit d2d7d69

Please sign in to comment.