Skip to content

Commit bba5e24

Browse files
Implemented commands
1 parent a680446 commit bba5e24

File tree

6 files changed

+82
-34
lines changed

6 files changed

+82
-34
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ ff
44
not_gitmodules.egg-info/
55
setup.py
66
*.pyc
7-
__pycache__/
7+
__pycache__/
8+
/notgitmodules.yaml
9+
/build/
10+
/my_gitmodules/
11+
/manual_test.py

README.md

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
## Why `not_gitmodules`?
66

7-
1. `not_gitmodules` demonstrate how simple and elegant `gitmodules` should be to those developers who enjoy their lives. Add and remove modules without caring about irrelevant stuff. No *
7+
1. `not_gitmodules` demonstrate how simple and elegant `gitmodules` should be to those developers who enjoy their lives.
8+
Add and remove modules without caring about irrelevant stuff. No *
89
*shitshow**, just simplicity.
910
2. Production-use friendly. This is documented in the license.
1011
3. No third-party libraries are required; only built-in tools are used.
@@ -21,48 +22,76 @@
2122
pip install not-gitmodules
2223
```
2324

25+
---
26+
Here's the updated `README.md` snippet with the changes you requested:
27+
2428
---
2529

2630
## Usage
2731

2832
1. **IMPORTANT:** Create a `notgitmodules.yaml` file in your project's root directory.
2933

30-
```yaml
31-
repos:
32-
# directory: url (ssh or https)
33-
34-
# Example
35-
file_reader: https://github.com/Free-Apps-for-All/file_manager_git_module
36-
```
34+
```yaml
35+
repos:
36+
# directory: url (ssh or https)
3737

38+
# Example
39+
file_reader: https://github.com/Free-Apps-for-All/file_manager_git_module
40+
```
3841
3942
2. Let `not_gitmodules` do the job.
4043

41-
- **Example with Code**:
44+
> ### Example with Code:
45+
>
46+
> Pass the path to the `initializer` function:
47+
> ```python
48+
> from not_gitmodules import initializer
49+
>
50+
> initializer('custom/path/to/notgitmodules.yaml')
51+
> ```
52+
> or
53+
> ```python
54+
> from not_gitmodules import initializer
55+
>
56+
> initializer() # if notgitmodules.yaml exists in the project root
57+
> ```
58+
59+
### Example with CLI:
60+
61+
#### 1. Install the library locally if you cloned the repo (**optional**) :
62+
63+
```bash
64+
pip install .
65+
```
66+
67+
---
4268

43-
Pass the path to the `initializer` function:
44-
```python
45-
from not_gitmodules import initializer
69+
#### 2. Install the modules directly from the terminal:
4670

47-
initializer('/path/to/notgitmodules.yaml')
48-
```
71+
>#### Flags
72+
>
73+
>| Flag | Description |
74+
>|---------------------|-------------------------------------------------------------------------|
75+
>| `-d`, `--dir_name` | Specify a directory name where the modules will be saved (optional). |
76+
>| `-y`, `--yaml-path` | Specify a custom location for the `notgitmodules.yaml` file (optional). |
4977

50-
- **Example with CLI**:
78+
### Default command:
5179

52-
Install the library locally if you cloned the repo:
80+
```bash
81+
not_gitmodules install
82+
```
5383

54-
```bash
55-
pip install .
56-
```
84+
### Command pattern:
5785

58-
Once installed, you can delete the local repo from your system (the library is now saved in the virtual environment
59-
or globally).
86+
```bash
87+
not_gitmodules install --yaml-path </path/to/notgitmodules.yaml> --dir_name <directory_name>
88+
```
6089

61-
Run the `not_gitmodules` command directly from the terminal:
90+
or
6291

63-
```bash
64-
not_gitmodules
65-
```
92+
```bash
93+
not_gitmodules install -y </path/to/notgitmodules.yaml> -d <directory_name>
94+
```
6695

6796
---
6897

dev-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
pytest==7.2.0
21
PyYAML~=6.0

not_gitmodules/cli.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
import argparse
12
from .core import initializer
23

34

45
def cli():
5-
yaml_path = input('Enter the custom path to notgitmodules.yaml, or press any button to skip if it is in the root.')
6-
if not yaml_path.strip():
7-
initializer(yaml_config_path='notgitmodules.yaml')
8-
else:
9-
initializer(yaml_path.strip())
6+
arg_parser = argparse.ArgumentParser(description="GitHub repositories installation with not_gitmodules.")
7+
8+
arg_parser.add_argument(
9+
"-y", "--yaml-path",
10+
nargs="?", # optional
11+
default="notgitmodules.yaml",
12+
help="Path to the custom YAML configuration file. By default it's notgitmodules.yaml."
13+
)
14+
15+
arg_parser.add_argument(
16+
"-d", "--dir_name",
17+
nargs="?", # optional
18+
default="my_gitmodules",
19+
help="The name of the directory the modules will be saved in. By default it's my_gitmodules."
20+
)
21+
22+
args = arg_parser.parse_args()
23+
24+
initializer(yaml_config_path=args.yaml_path, root_dir_name=args.dir_name)

not_gitmodules/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def initializer(
66
yaml_config_path: str = 'notgitmodules.yaml',
7-
root_dir_name="no_gitmodules"
7+
root_dir_name="my_gitmodules"
88
):
99
"""
1010
:param yaml_config_path: The path to notgitmodules.yaml file

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
setup(
44
name='not_gitmodules',
5-
version='0.1.3.1',
5+
version='0.1.3.2',
66
packages=find_packages(),
77
license='Custom License',
88
entry_points={
99
'console_scripts': [
10+
'not_gitmodules install=not_gitmodules.cli:cli',
1011
'not_gitmodules=not_gitmodules.cli:cli',
1112
],
1213
},

0 commit comments

Comments
 (0)