backant-cli 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- backant_cli-0.7.3/MANIFEST.in +2 -0
- backant_cli-0.7.3/PKG-INFO +220 -0
- backant_cli-0.7.3/README.md +191 -0
- backant_cli-0.7.3/ant/__init__.py +0 -0
- backant_cli-0.7.3/ant/cli.py +51 -0
- backant_cli-0.7.3/ant/commands/__init__.py +1 -0
- backant_cli-0.7.3/ant/commands/generate.py +1120 -0
- backant_cli-0.7.3/ant/commands/generate_schema.py +128 -0
- backant_cli-0.7.3/ant/commands/templates/__init__.py +1 -0
- backant_cli-0.7.3/ant/commands/templates/base/.env +11 -0
- backant_cli-0.7.3/ant/commands/templates/base/.github/workflows/build_and_push_to_ecr.yml +58 -0
- backant_cli-0.7.3/ant/commands/templates/base/.gitignore +165 -0
- backant_cli-0.7.3/ant/commands/templates/base/Dockerfile +22 -0
- backant_cli-0.7.3/ant/commands/templates/base/README.md +74 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/.env.testing +11 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/.gitattributes +2 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/apis/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/apis/aws/AWSClient.py +30 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/app.py +41 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/decorators/token_required.py +46 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/DBSession.py +71 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/execution_tracking/APIException.py +15 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/execution_tracking/Logger.py +38 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/execution_tracking/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/functions/extract_fields.py +10 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/functions/log_directory_contents.py +24 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/functions/update_dict.py +9 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/functions/update_measurement.py +6 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/helper/functions/validation_error.py +9 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/models/Default_model.py +18 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/models/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/repositories/Repository.py +22 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/repositories/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/repositories/default_repository.py +43 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/routes/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/routes/default_route.py +10 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/schemas/PostDefault_schema.py +5 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/schemas/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/services/__init__.py +0 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/services/default_service.py +15 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/startup/Alchemy.py +47 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/startup/Environment.py +35 -0
- backant_cli-0.7.3/ant/commands/templates/base/api/startup/__init__.py +8 -0
- backant_cli-0.7.3/ant/commands/templates/base/docker-compose-prod.yml +14 -0
- backant_cli-0.7.3/ant/commands/templates/base/docker-compose.yml +27 -0
- backant_cli-0.7.3/ant/commands/templates/base/pylintrc +6 -0
- backant_cli-0.7.3/ant/commands/templates/base/requirements.txt +57 -0
- backant_cli-0.7.3/ant/utils/__init__.py +0 -0
- backant_cli-0.7.3/ant/utils/report_builder.py +29 -0
- backant_cli-0.7.3/ant/utils/telemetry.py +480 -0
- backant_cli-0.7.3/backant_cli.egg-info/PKG-INFO +220 -0
- backant_cli-0.7.3/backant_cli.egg-info/SOURCES.txt +58 -0
- backant_cli-0.7.3/backant_cli.egg-info/dependency_links.txt +1 -0
- backant_cli-0.7.3/backant_cli.egg-info/entry_points.txt +2 -0
- backant_cli-0.7.3/backant_cli.egg-info/requires.txt +8 -0
- backant_cli-0.7.3/backant_cli.egg-info/top_level.txt +1 -0
- backant_cli-0.7.3/setup.cfg +4 -0
- backant_cli-0.7.3/setup.py +28 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: backant-cli
|
|
3
|
+
Version: 0.7.3
|
|
4
|
+
Summary: A CLI tool to generate backant backend projects
|
|
5
|
+
Home-page: https://github.com/backant/backant-cli
|
|
6
|
+
Author: Pavel Hegler
|
|
7
|
+
Author-email: business@hegler.tech
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: click
|
|
13
|
+
Requires-Dist: pydantic>=2.0
|
|
14
|
+
Requires-Dist: posthog>=3.0.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: ruff; extra == "dev"
|
|
17
|
+
Requires-Dist: black; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest; extra == "dev"
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: provides-extra
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# Backant CLI
|
|
31
|
+
|
|
32
|
+
Backant CLI is a powerful Linux native command-line interface designed to streamline the development of Flask-based REST APIs. It automates the generation of a complete and scalable project structure, allowing developers to focus on business logic rather than boilerplate code.
|
|
33
|
+
|
|
34
|
+
## Key Features
|
|
35
|
+
|
|
36
|
+
- **Automated Project Scaffolding**: Generate a new Flask API with a single command, including a well-organized directory structure.
|
|
37
|
+
- **Layered Architecture**: The generated project follows a clean, layered architecture (Models, Repositories, Services, Routes) to promote separation of concerns and maintainability.
|
|
38
|
+
- **Database-Ready**: Includes SQLAlchemy for database modeling and interaction, with a pre-configured `DBSession` for easy database access.
|
|
39
|
+
- **Dockerized Environment**: Comes with `Dockerfile` and `docker-compose.yml` files for a consistent development and production environment.
|
|
40
|
+
- **Extensible by Design**: Easily add new routes, services, and models using the provided CLI commands.
|
|
41
|
+
- **Pre-configured for Deployment**: Includes a GitHub Actions workflow for building and pushing Docker images to Amazon ECR.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
### Ubuntu/Debian (Recommended)
|
|
46
|
+
|
|
47
|
+
Install the Backant CLI using the .deb package for Ubuntu/Debian systems:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Download and install the .deb package
|
|
51
|
+
sudo dpkg -i backant-cli.deb
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Alternative: Python Package
|
|
55
|
+
|
|
56
|
+
You can also install using pip:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install backant-cli
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Getting Started
|
|
63
|
+
|
|
64
|
+
### Generating a New API
|
|
65
|
+
|
|
66
|
+
To create a new Flask API project, use the `generate api` command:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
ant generate api <your_project_name>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This will create a new directory named `<your_project_name>` with the complete project structure.
|
|
73
|
+
|
|
74
|
+
### Generating API from JSON Specification
|
|
75
|
+
|
|
76
|
+
You can generate a complete API with routes and subroutes from a JSON specification using the `--json` option:
|
|
77
|
+
|
|
78
|
+
#### Using JSON String:
|
|
79
|
+
```bash
|
|
80
|
+
ant generate api my-project --json '{"routes": {"products": {"type": "GET", "subroutes": {"create": {"type": "POST"}}}}}'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Using JSON File:
|
|
84
|
+
```bash
|
|
85
|
+
ant generate api ecommerce --json api-spec.json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Additional Options:
|
|
89
|
+
- `--verbose` or `-v`: Show detailed generation progress
|
|
90
|
+
- `--dry-run`: Validate JSON specification without generating files
|
|
91
|
+
|
|
92
|
+
#### Examples:
|
|
93
|
+
```bash
|
|
94
|
+
# Generate API with verbose output
|
|
95
|
+
ant generate api shop --json api-spec.json --verbose
|
|
96
|
+
|
|
97
|
+
# Validate JSON specification without creating files
|
|
98
|
+
ant generate api test --json api.json --dry-run
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### JSON Specification Format:
|
|
102
|
+
The JSON specification should follow this structure:
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"routes": {
|
|
106
|
+
"route_name": {
|
|
107
|
+
"type": "GET|POST|PUT|DELETE",
|
|
108
|
+
"mock": {},
|
|
109
|
+
"subroutes": {
|
|
110
|
+
"subroute_name": {
|
|
111
|
+
"type": "GET|POST|PUT|DELETE",
|
|
112
|
+
"mock": {}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Generating a New Route
|
|
121
|
+
|
|
122
|
+
Once you have a project, you can easily add new routes and their corresponding components (service, repository, model) with the `generate route` command:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
ant generate route <your_route_name>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This command will automatically create:
|
|
129
|
+
- A new route in `api/routes/`
|
|
130
|
+
- A new service in `api/services/`
|
|
131
|
+
- A new repository in `api/repositories/`
|
|
132
|
+
- A new model in `api/models/`
|
|
133
|
+
|
|
134
|
+
### Generating a Mock Route
|
|
135
|
+
|
|
136
|
+
You can also generate a route with mock data for testing and development purposes. Use the `--mock` option with a JSON string or a path to a JSON file.
|
|
137
|
+
|
|
138
|
+
#### Using a JSON String:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
ant generate route <your_route_name> --mock '{"key": "value", "another_key": "another_value"}'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Using a JSON File:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
ant generate route <your_route_name> --mock /path/to/your/mock_data.json
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
This will generate the same files as the standard `generate route` command, but the service will return the provided JSON data.
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
## Project Structure
|
|
154
|
+
|
|
155
|
+
The generated project follows a structured and scalable architecture:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
<your_project_name>/
|
|
159
|
+
├── api/
|
|
160
|
+
│ ├── apis/ # For third-party API integrations
|
|
161
|
+
│ ├── decorators/ # Custom decorators (e.g., for authentication)
|
|
162
|
+
│ ├── helper/ # Helper functions and utilities
|
|
163
|
+
│ ├── models/ # SQLAlchemy database models
|
|
164
|
+
│ ├── repositories/ # Data access layer
|
|
165
|
+
│ ├── routes/ # API endpoints (controllers)
|
|
166
|
+
│ ├── schemas/ # Data validation schemas
|
|
167
|
+
│ ├── services/ # Business logic layer
|
|
168
|
+
│ └── startup/ # Application startup and configuration
|
|
169
|
+
├── .github/
|
|
170
|
+
│ └── workflows/ # CI/CD workflows
|
|
171
|
+
├── .gitignore
|
|
172
|
+
├── docker-compose.yml
|
|
173
|
+
├── Dockerfile
|
|
174
|
+
└── requirements.txt
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Telemetry
|
|
178
|
+
|
|
179
|
+
BackAnt CLI includes **opt-in** anonymous telemetry to help us improve the tool. On first run, you'll be asked if you want to participate.
|
|
180
|
+
|
|
181
|
+
### Quick Disable
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Environment variable (permanent)
|
|
185
|
+
export DO_NOT_TRACK=1
|
|
186
|
+
|
|
187
|
+
# Per-command flag
|
|
188
|
+
ant --no-telemetry generate api my-project
|
|
189
|
+
|
|
190
|
+
# View telemetry settings
|
|
191
|
+
ant --privacy
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
We **never** collect file paths, project names, usernames, or any personally identifiable information. See [docs/telemetry.md](docs/telemetry.md) for full details.
|
|
195
|
+
|
|
196
|
+
## Contributing
|
|
197
|
+
|
|
198
|
+
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
|
|
199
|
+
|
|
200
|
+
### Development Setup
|
|
201
|
+
|
|
202
|
+
1. **Clone the repository:**
|
|
203
|
+
```bash
|
|
204
|
+
git clone https://github.com/backant/backant-cli.git
|
|
205
|
+
```
|
|
206
|
+
2. **Create a virtual environment:**
|
|
207
|
+
```bash
|
|
208
|
+
python3 -m venv venv
|
|
209
|
+
source venv/bin/activate
|
|
210
|
+
```
|
|
211
|
+
3. **Install the dependencies:**
|
|
212
|
+
```bash
|
|
213
|
+
pip install -r requirements.txt
|
|
214
|
+
```
|
|
215
|
+
4. **Install the CLI in editable mode:**
|
|
216
|
+
```bash
|
|
217
|
+
pip install -e .
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Now you can run the CLI locally using the `ant` command.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Backant CLI
|
|
2
|
+
|
|
3
|
+
Backant CLI is a powerful Linux native command-line interface designed to streamline the development of Flask-based REST APIs. It automates the generation of a complete and scalable project structure, allowing developers to focus on business logic rather than boilerplate code.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- **Automated Project Scaffolding**: Generate a new Flask API with a single command, including a well-organized directory structure.
|
|
8
|
+
- **Layered Architecture**: The generated project follows a clean, layered architecture (Models, Repositories, Services, Routes) to promote separation of concerns and maintainability.
|
|
9
|
+
- **Database-Ready**: Includes SQLAlchemy for database modeling and interaction, with a pre-configured `DBSession` for easy database access.
|
|
10
|
+
- **Dockerized Environment**: Comes with `Dockerfile` and `docker-compose.yml` files for a consistent development and production environment.
|
|
11
|
+
- **Extensible by Design**: Easily add new routes, services, and models using the provided CLI commands.
|
|
12
|
+
- **Pre-configured for Deployment**: Includes a GitHub Actions workflow for building and pushing Docker images to Amazon ECR.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Ubuntu/Debian (Recommended)
|
|
17
|
+
|
|
18
|
+
Install the Backant CLI using the .deb package for Ubuntu/Debian systems:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Download and install the .deb package
|
|
22
|
+
sudo dpkg -i backant-cli.deb
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Alternative: Python Package
|
|
26
|
+
|
|
27
|
+
You can also install using pip:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install backant-cli
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Getting Started
|
|
34
|
+
|
|
35
|
+
### Generating a New API
|
|
36
|
+
|
|
37
|
+
To create a new Flask API project, use the `generate api` command:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
ant generate api <your_project_name>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This will create a new directory named `<your_project_name>` with the complete project structure.
|
|
44
|
+
|
|
45
|
+
### Generating API from JSON Specification
|
|
46
|
+
|
|
47
|
+
You can generate a complete API with routes and subroutes from a JSON specification using the `--json` option:
|
|
48
|
+
|
|
49
|
+
#### Using JSON String:
|
|
50
|
+
```bash
|
|
51
|
+
ant generate api my-project --json '{"routes": {"products": {"type": "GET", "subroutes": {"create": {"type": "POST"}}}}}'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Using JSON File:
|
|
55
|
+
```bash
|
|
56
|
+
ant generate api ecommerce --json api-spec.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### Additional Options:
|
|
60
|
+
- `--verbose` or `-v`: Show detailed generation progress
|
|
61
|
+
- `--dry-run`: Validate JSON specification without generating files
|
|
62
|
+
|
|
63
|
+
#### Examples:
|
|
64
|
+
```bash
|
|
65
|
+
# Generate API with verbose output
|
|
66
|
+
ant generate api shop --json api-spec.json --verbose
|
|
67
|
+
|
|
68
|
+
# Validate JSON specification without creating files
|
|
69
|
+
ant generate api test --json api.json --dry-run
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### JSON Specification Format:
|
|
73
|
+
The JSON specification should follow this structure:
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"routes": {
|
|
77
|
+
"route_name": {
|
|
78
|
+
"type": "GET|POST|PUT|DELETE",
|
|
79
|
+
"mock": {},
|
|
80
|
+
"subroutes": {
|
|
81
|
+
"subroute_name": {
|
|
82
|
+
"type": "GET|POST|PUT|DELETE",
|
|
83
|
+
"mock": {}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Generating a New Route
|
|
92
|
+
|
|
93
|
+
Once you have a project, you can easily add new routes and their corresponding components (service, repository, model) with the `generate route` command:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
ant generate route <your_route_name>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This command will automatically create:
|
|
100
|
+
- A new route in `api/routes/`
|
|
101
|
+
- A new service in `api/services/`
|
|
102
|
+
- A new repository in `api/repositories/`
|
|
103
|
+
- A new model in `api/models/`
|
|
104
|
+
|
|
105
|
+
### Generating a Mock Route
|
|
106
|
+
|
|
107
|
+
You can also generate a route with mock data for testing and development purposes. Use the `--mock` option with a JSON string or a path to a JSON file.
|
|
108
|
+
|
|
109
|
+
#### Using a JSON String:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
ant generate route <your_route_name> --mock '{"key": "value", "another_key": "another_value"}'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Using a JSON File:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
ant generate route <your_route_name> --mock /path/to/your/mock_data.json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This will generate the same files as the standard `generate route` command, but the service will return the provided JSON data.
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## Project Structure
|
|
125
|
+
|
|
126
|
+
The generated project follows a structured and scalable architecture:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
<your_project_name>/
|
|
130
|
+
├── api/
|
|
131
|
+
│ ├── apis/ # For third-party API integrations
|
|
132
|
+
│ ├── decorators/ # Custom decorators (e.g., for authentication)
|
|
133
|
+
│ ├── helper/ # Helper functions and utilities
|
|
134
|
+
│ ├── models/ # SQLAlchemy database models
|
|
135
|
+
│ ├── repositories/ # Data access layer
|
|
136
|
+
│ ├── routes/ # API endpoints (controllers)
|
|
137
|
+
│ ├── schemas/ # Data validation schemas
|
|
138
|
+
│ ├── services/ # Business logic layer
|
|
139
|
+
│ └── startup/ # Application startup and configuration
|
|
140
|
+
├── .github/
|
|
141
|
+
│ └── workflows/ # CI/CD workflows
|
|
142
|
+
├── .gitignore
|
|
143
|
+
├── docker-compose.yml
|
|
144
|
+
├── Dockerfile
|
|
145
|
+
└── requirements.txt
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Telemetry
|
|
149
|
+
|
|
150
|
+
BackAnt CLI includes **opt-in** anonymous telemetry to help us improve the tool. On first run, you'll be asked if you want to participate.
|
|
151
|
+
|
|
152
|
+
### Quick Disable
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Environment variable (permanent)
|
|
156
|
+
export DO_NOT_TRACK=1
|
|
157
|
+
|
|
158
|
+
# Per-command flag
|
|
159
|
+
ant --no-telemetry generate api my-project
|
|
160
|
+
|
|
161
|
+
# View telemetry settings
|
|
162
|
+
ant --privacy
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
We **never** collect file paths, project names, usernames, or any personally identifiable information. See [docs/telemetry.md](docs/telemetry.md) for full details.
|
|
166
|
+
|
|
167
|
+
## Contributing
|
|
168
|
+
|
|
169
|
+
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
|
|
170
|
+
|
|
171
|
+
### Development Setup
|
|
172
|
+
|
|
173
|
+
1. **Clone the repository:**
|
|
174
|
+
```bash
|
|
175
|
+
git clone https://github.com/backant/backant-cli.git
|
|
176
|
+
```
|
|
177
|
+
2. **Create a virtual environment:**
|
|
178
|
+
```bash
|
|
179
|
+
python3 -m venv venv
|
|
180
|
+
source venv/bin/activate
|
|
181
|
+
```
|
|
182
|
+
3. **Install the dependencies:**
|
|
183
|
+
```bash
|
|
184
|
+
pip install -r requirements.txt
|
|
185
|
+
```
|
|
186
|
+
4. **Install the CLI in editable mode:**
|
|
187
|
+
```bash
|
|
188
|
+
pip install -e .
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Now you can run the CLI locally using the `ant` command.
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from ant.commands.generate import generate
|
|
3
|
+
from ant.utils.telemetry import (
|
|
4
|
+
telemetry_callback,
|
|
5
|
+
privacy_callback,
|
|
6
|
+
telemetry_group_callback,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
|
|
11
|
+
@click.option(
|
|
12
|
+
"--report",
|
|
13
|
+
is_flag=True,
|
|
14
|
+
default=False,
|
|
15
|
+
help="Output machine-readable JSON report to stdout",
|
|
16
|
+
)
|
|
17
|
+
@click.option(
|
|
18
|
+
"--no-telemetry",
|
|
19
|
+
is_flag=True,
|
|
20
|
+
default=False,
|
|
21
|
+
expose_value=False,
|
|
22
|
+
is_eager=True,
|
|
23
|
+
callback=telemetry_callback,
|
|
24
|
+
help="Disable telemetry for this session",
|
|
25
|
+
)
|
|
26
|
+
@click.option(
|
|
27
|
+
"--privacy",
|
|
28
|
+
is_flag=True,
|
|
29
|
+
default=False,
|
|
30
|
+
expose_value=False,
|
|
31
|
+
is_eager=True,
|
|
32
|
+
callback=privacy_callback,
|
|
33
|
+
help="Show telemetry and privacy information",
|
|
34
|
+
)
|
|
35
|
+
@click.pass_context
|
|
36
|
+
def main(ctx, report):
|
|
37
|
+
"""BackAnt CLI - Generate Flask REST API projects.
|
|
38
|
+
|
|
39
|
+
A powerful command-line interface to streamline Flask-based REST API development.
|
|
40
|
+
"""
|
|
41
|
+
ctx.ensure_object(dict)
|
|
42
|
+
ctx.obj["report"] = report
|
|
43
|
+
|
|
44
|
+
# Initialize telemetry (handles first-run consent prompt)
|
|
45
|
+
telemetry_group_callback(ctx)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
main.add_command(generate)
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Empty file to make commands a package
|