Supplemented commands documentation

This commit is contained in:
mdnapo 2024-07-15 00:14:21 +02:00
parent be6b3691b4
commit 9d1442b46b
38 changed files with 646 additions and 26 deletions

View File

@ -8,12 +8,12 @@ public partial class MycroForge
{
public partial class Db
{
public partial class Stop : Command, ISubCommandOf<Db>
public class Stop : Command, ISubCommandOf<Db>
{
private readonly ProjectContext _context;
public Stop(ProjectContext context) :
base("stop", $"Stops {Features.Db.FeatureName}.docker-compose.yml")
base("stop", $"Stops the services defined in {Features.Db.FeatureName}.docker-compose.yml")
{
_context = context;
this.SetHandler(ExecuteAsync);

View File

@ -10,13 +10,13 @@ public static class ServiceCollectionExtensions
{
public static IServiceCollection RegisterCommandDefaults(this IServiceCollection services)
{
// Register ProjectContext & features
// Register ProjectContext, OptionsContainer & features
services.AddScoped<ProjectContext>();
services.AddScoped<OptionsContainer>();
services.AddScoped<IFeature, Api>();
services.AddScoped<IFeature, Db>();
services.AddScoped<IFeature, Git>();
services.AddScoped<IFeature, GitIgnore>();
services.AddScoped<OptionsContainer>();
// Register "m4g"
services.AddScoped<Commands.MycroForge>();

View File

@ -1 +1,24 @@
# Commands
```
Description:
The MycroForge CLI tool.
Usage:
m4g [command] [options]
Options:
--version Show version information
-?, -h, --help Show help and usage information
Commands:
init <name> Initialize a new project
i, install <packages> Install packages and update the requirements.txt
u, uninstall <packages> Uninstall packages and update the requirements.txt
hydrate Initialize venv and install dependencies from requirements.txt
add Add features to the project
g, generate Generate common items
api API related commands
db Database related commands
p, plugin Plugin related commands
```

View File

@ -1,19 +0,0 @@
---
sidebar_position: 1
---
# Init
```
Description:
Initialize a new project
Usage:
m4g init <name> [options]
Arguments:
<name> The name of your project
Options:
--without <api|db|git> Features to exclude
-?, -h, --help Show help and usage information

View File

@ -0,0 +1,22 @@
---
sidebar_position: 1
---
# m4g add
```
Description:
Add features to the project
Usage:
m4g add [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
api Add FastAPI to the project
db Add SQLAlchemy & Alembic to the project
git Add git to the project
gitignore Add a default .gitignore file to the project
```

View File

@ -0,0 +1,17 @@
---
sidebar_position: 1
---
# m4g add api
```
Description:
Add FastAPI to the project
Usage:
m4g add api [options]
Options:
--api-port <api-port> The API port
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,18 @@
---
sidebar_position: 1
---
# m4g add db
```
Description:
Add SQLAlchemy & Alembic to the project
Usage:
m4g add db [options]
Options:
--database-host-port, --dbh-port <database-host-port> The database host port
--database-ui-port, --dbu-port <database-ui-port> The database UI port
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g add git
```
Description:
Add git to the project
Usage:
m4g add git [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g add gitignore
```
Description:
Add a default .gitignore file to the project
Usage:
m4g add gitignore [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,20 @@
---
sidebar_position: 1
---
# m4g api
```
Description:
API related commands
Usage:
m4g api [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
run Run your app
g, generate Generate an API item
```

View File

@ -0,0 +1,20 @@
---
sidebar_position: 1
---
# m4g api generate
```
Description:
Generate an API item
Usage:
m4g api generate [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
r, router <name> Generate an api router
crud <entity> Generated CRUD functionality for an entity
```

View File

@ -0,0 +1,19 @@
---
sidebar_position: 1
---
# m4g api generate crud
```
Description:
Generated CRUD functionality for an entity
Usage:
m4g api generate crud <entity> [options]
Arguments:
<entity> The entity to target
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,19 @@
---
sidebar_position: 1
---
# m4g api generate router
```
Description:
Generate an api router
Usage:
m4g api generate router <name> [options]
Arguments:
<name> The name of the api router
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g api run
```
Description:
Run your app
Usage:
m4g api run [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,24 @@
---
sidebar_position: 1
---
# m4g db
```
Description:
Database related commands
Usage:
m4g db [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
run Runs the services defined in db.docker-compose.yml
stop Stops db.docker-compose.yml
migrate Apply migrations to the database
rollback Rollback the last migration
g, generate Generate a database item
link Define relationships between entities
```

View File

@ -0,0 +1,20 @@
---
sidebar_position: 1
---
# m4g db generate
```
Description:
Generate a database item
Usage:
m4g db generate [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
e, entity <name> Generate and database entity
m, migration <name> Generate a migration
```

View File

@ -0,0 +1,35 @@
---
sidebar_position: 1
---
# m4g db generate entity
```
Description:
Generate and database entity
Usage:
m4g db generate entity <name> [options]
Arguments:
<name> The name of the database entity
Supported formats:
Entity
path/relative/to/entities:Entity
Options:
-c, --column <column> Specify the fields to add.
Format:
<name>:<native_type>:<orm_type>
<name> = Name of the column
<native_type> = The native Python type
<orm_type> = The SQLAlchemy type
Example:
first_name:str:String(255)
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,19 @@
---
sidebar_position: 1
---
# m4g db generate migration
```
Description:
Generate a migration
Usage:
m4g db generate migration <name> [options]
Arguments:
<name> The name of the migration
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,21 @@
---
sidebar_position: 1
---
# m4g db link
```
Description:
Define relationships between entities
Usage:
m4g db link [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
one <entity> Define a 1:n relation
many <entity> Define a n:m relation
```

View File

@ -0,0 +1,21 @@
---
sidebar_position: 1
---
# m4g db link many
```
Description:
Define a n:m relation
Usage:
m4g db link many <entity> [options]
Arguments:
<entity> The left side of the relation
Options:
--to-one <to-one> The right side of the relation
--to-many <to-many> The right side of the relation
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,21 @@
---
sidebar_position: 1
---
# m4g db link one
```
Description:
Define a 1:n relation
Usage:
m4g db link one <entity> [options]
Arguments:
<entity> The left side of the relation
Options:
--to-one <to-one> The right side of the relation
--to-many <to-many> The right side of the relation
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g db migrate
```
Description:
Apply migrations to the database
Usage:
m4g db migrate [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g db rollback
```
Description:
Rollback the last migration
Usage:
m4g db rollback [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g db run
```
Description:
Runs the services defined in db.docker-compose.yml
Usage:
m4g db run [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g db stop
```
Description:
Stops db.docker-compose.yml
Usage:
m4g db stop [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,20 @@
---
sidebar_position: 1
---
# m4g generate
```
Description:
Generate common items
Usage:
m4g generate [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
s, service <name> Generate a service
venv Generate a venv
```

View File

@ -0,0 +1,20 @@
---
sidebar_position: 1
---
# m4g generate service
```
Description:
Generate a service
Usage:
m4g generate service <name> [options]
Arguments:
<name> The name of the service
Options:
--with-session Create a service that uses database sessions
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g generate venv
```
Description:
Generate a venv
Usage:
m4g generate venv [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g hydrate
```
Description:
Initialize venv and install dependencies from requirements.txt
Usage:
m4g hydrate [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,23 @@
---
sidebar_position: 1
---
# m4g init
```
Description:
Initialize a new project
Usage:
m4g init <name> [options]
Arguments:
<name> The name of your project
Options:
--without <api|db|git|gitignore> Features to exclude
--api-port <api-port> The API port
--database-host-port, --dbh-port <database-host-port> The database host port
--database-ui-port, --dbu-port <database-ui-port> The database UI port
-?, -h, --help Show help and usage information
```

View File

@ -2,7 +2,7 @@
sidebar_position: 1
---
# Install
# m4g install
```
Description:

View File

@ -0,0 +1,22 @@
---
sidebar_position: 1
---
# m4g plugin
```
Description:
Plugin related commands
Usage:
m4g plugin [command] [options]
Options:
-?, -h, --help Show help and usage information
Commands:
init <name> Initialize a basic plugin project
l, list, ls List all installed plugins
i, install Install a plugin
u, uninstall <name> Uninstall a plugin
```

View File

@ -0,0 +1,19 @@
---
sidebar_position: 1
---
# m4g plugin init
```
Description:
Initialize a basic plugin project
Usage:
m4g plugin init <name> [options]
Arguments:
<name> The name of your project
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,17 @@
---
sidebar_position: 1
---
# m4g plugin install
```
Description:
Install a plugin
Usage:
m4g plugin install [options]
Options:
-p, --platform <linux_arm|linux_arm64|linux_x64|osx_arm64|osx_x64> (REQUIRED) The platform to target when building the plugin
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,16 @@
---
sidebar_position: 1
---
# m4g plugin list
```
Description:
List all installed plugins
Usage:
m4g plugin list [options]
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,19 @@
---
sidebar_position: 1
---
# m4g plugin uninstall
```
Description:
Uninstall a plugin
Usage:
m4g plugin uninstall [<name>...] [options]
Arguments:
<name> The names of the plugins you want to uninstall
Options:
-?, -h, --help Show help and usage information
```

View File

@ -0,0 +1,20 @@
---
sidebar_position: 1
---
# m4g uninstall
```
Description:
Uninstall packages and update the requirements.txt
Usage:
m4g uninstall [<packages>...] [options]
Arguments:
<packages> The names of the packages to uninstall
Options:
-y, --yes Dont ask for confirmation of uninstall deletions
-?, -h, --help Show help and usage information
```

View File

@ -64,7 +64,7 @@ const config: Config = {
label: 'Docs',
},
{
href: 'https://git.devdisciples.com/devdisciplies/mycroforge',
href: 'https://git.devdisciples.com/devdisciples/mycroforge',
label: 'Git',
position: 'right',
},