Skip to content

Commit

Permalink
Renewed Docstrings and Helptexts (#110)
Browse files Browse the repository at this point in the history
* documentation

* Update README.md

Co-authored-by: Jan Max Meyer <[email protected]>

* Update README.md

Co-authored-by: Jan Max Meyer <[email protected]>

* Update README.md

Co-authored-by: Jan Max Meyer <[email protected]>

* Update README.md

Co-authored-by: Jan Max Meyer <[email protected]>

* Update README.md

Co-authored-by: Jan Max Meyer <[email protected]>

* Update README.md

Co-authored-by: Jan Max Meyer <[email protected]>

* Update README.md

Co-authored-by: Jan Max Meyer <[email protected]>

---------

Co-authored-by: Jan Max Meyer <[email protected]>
  • Loading branch information
Grashalmbeisser and phorward authored Feb 23, 2024
1 parent edd1273 commit adb5f3f
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 308 deletions.
89 changes: 55 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
</div>

## What does it do?
`viur-cli` allows to control, maintain and develop a ViUR project from one central location by using the `viur` command.
`viur-cli` allows to control, maintain, develop and deploy a ViUR project from one central
location by using the `viur` command.


## Installation
Expand All @@ -26,39 +27,33 @@ $ pipenv install --dev viur-cli
## Usage

```sh
$ viur --help
$ viur -h
```
will show all the commands that are currently supported by viur-cli

```sh
$ viur --version
```
will show your current viur-cli version


```sh
$ viur create myapp
```
this will create a new project folder, clone the base project and then call `viur init` to prepare a project.json
you can use this to get started quickly with a new viur project from scratch.

```sh
$ viur init
$ viur run [profile]
```
this will initialize a new project in the current folder, you will be asked a couple of questions like if
you would like to create a new project.json file, what components should be preinstalled and what the
projectID of your application will be.
run the appserver and start your app locally. You may specify a target profile.

```sh
$ viur run [target]
```
run the appserver and start your app locally. You may specify a target projectID.

```sh
$ viur check {npm|--dev|--autofix}
$ viur check [--dev]
```
Runs a security check for the python environment and for each npm project registered under builds.

```sh
$ viur enable {backup}
```
create a backup bucket and enable the gcloud service worker account to access it.


```sh
$ viur package {install|update} {vi|scriptor|admin|all}
```
Expand All @@ -73,25 +68,24 @@ Arguments:
- `version` version to install

```sh
$ viur build release
```
build all npm apps and produce a release that can be deployed

```sh
$ viur build app [appname]
$ viur build {app|clean|release} [option]
```
build a specific app
Builds ViUR Project or specific apps
Commands:
- `app` Build a specific application
- `clean` Clean up Build Artifacts
- `release` Build all relevant applications to deploy the project

```sh
$ viur cloud deploy {app|index|cloudfunction} {profile} {--ext|--yes|--name}
```
This Function deploys the Google Cloud application and / or different .yaml files
Scripts:
- `app` Deploy application to the Google Appengine
- `index` Deploy index.yaml to Google Appenginge
- `cloudfunction` Deploy Cloudfunction to Google Appengine
Commands:
- `profile` The project.json profile you want to Work from
- `index` Deploy index.yaml to Google Appenginge
- `cloudfunction` Deploy Cloudfunction to Google Appengine
Commands:
- `profile` The project.json profile you want to Work from


```sh
Expand All @@ -104,7 +98,7 @@ $ viur cloud setup {gcloud|gcroles}
```
Scripts:
- `gcloud` This Function setups your project to work on the gcloud plattform
- `gcroles` This function lets you set up Roles for your google appengine Workspace
- `gcroles` This function lets you set up Roles for your google appengine Workspace


```sh
Expand All @@ -113,17 +107,30 @@ $ viur cloud get {gcroles}
Scripts:
- `gcroles` This function lets you get Roles for your google appengine Workspace in a readable .json Format

```sh
$ viur package {update|install} {vi|admin|scriptor|all} [profile] [version]
```
Performs operations on packages

Scripts:
- `update` Updates an installed package
- `install` Installs a declared package

Options:
- `vi`
- `admin`
- `scriptor`
- `all`

```sh
$ viur env
```
check the environment you are in right now, show versions of viur-cli, viur-core and vi etc.
Show information about your current environment.

```sh
$ viur project {add|remove|list}
$ viur project list
```
with this you can manage your project.json or generate a new one. You can add or remove targets to/from the
project.json, list what has been added to the project.json, to be built when running `viur build release`.
Pretty prints your `project.json` file on the console.

```sh
$ viur update {requirements}
Expand Down Expand Up @@ -162,6 +169,20 @@ It contains the default viur project profile and it can be expanded with several
"source": ""
}
},
"gcloud": {
"functions": { //Declarations for a cloud function
"testfunction1": {
"entry-point": "main",
"env-vars-file": "env.yaml",
"memory": "512MB",
"runtime": "python311",
"source": "deploy/cloudfunction/function1",
"trigger": "http"
}
},
"max-instances": "1",
"region": "europe-west3"
},
"core": "3.5.1", // viur-core version of your project
"distribution_folder": "./deploy", // Deploy folder uploaded to GAE
"sources_folder": "./sources",
Expand All @@ -184,6 +205,7 @@ The GUI version is called scriptor and can be accessed via a webinterface, but v
```sh
$ viur script {configure|pull|push|run|setup}
```
Manage your ViUR Scriptor Scripts via the CLI
Commands:
- `configure` Manage configuration settings.
- `pull` Pull contents from server to working_dir.
Expand Down Expand Up @@ -240,7 +262,6 @@ viur-cli depends on
* [app_server](https://github.com/XeoN-GHMB/app_server)
* [pipfile-requirements](https://github.com/frostming/pipfile-requirements)
* [watchgod](https://github.com/samuelcolvin/watchgod)
* [python-minifier](https://github.com/dflook/python-minifier)

## License

Expand Down
2 changes: 0 additions & 2 deletions src/viur_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from .cli import *
from .conf import *
from .install import *
from .deploy import *
from .package import *
from .local import *
from .build import *
Expand Down
53 changes: 20 additions & 33 deletions src/viur_cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


def _build(conf, name, build_cfg, additional_args):
"""Internal function to perform steps required for a given build configuration.
"""
Internal function to perform steps required for a given build configuration.
This internal function is responsible for building an application according to the specified build configuration.
It can handle two types of builds:
Expand Down Expand Up @@ -39,6 +40,7 @@ def _build(conf, name, build_cfg, additional_args):
:return: None
"""

utils.echo_info(f"""- {build_cfg["kind"]} {name}""")
match build_cfg["kind"]:
case "npm":
Expand All @@ -60,7 +62,8 @@ def _build(conf, name, build_cfg, additional_args):


def _clean(conf, name, build_cfg):
"""Perform steps required to clean a given build configuration.
"""
Perform steps required to clean a given build configuration.
This internal function is responsible for cleaning the artifacts and files generated during the build process
for a specified application. It supports two types of cleaning methods:
Expand Down Expand Up @@ -137,23 +140,16 @@ def release(profile, additional_args):
This command is used to build all relevant applications necessary for deploying the project. It allows you to
specify the project configuration to use and any additional arguments to pass to the build process.
:param name: str, default: 'develop'
The name of the project configuration to use for building. This configuration can be either 'default' or a
project-specific configuration.
:param additional_args: tuple
Additional arguments that can be passed to the build process. These arguments are passed to the underlying
build functions.
The `release` command loads the specified project configuration, which includes build configurations for
individual applications. It then iterates through the applications and executes the build process for each one
using the `_build` function.
Note:
- Ensure that the specified project configuration exists.
- Additional arguments can be used to customize the build process.
:return: None
- Ensure that the specified project configuration exists.
- Additional arguments can be used to customize the build process.
"""
conf = config.get_profile(profile)
utils.echo_info("building started...")
Expand All @@ -175,21 +171,14 @@ def app(appname, profile, additional_args):
This function is used to build a specific application as defined in your project's configuration. It allows you to
specify the name of the application to build and any additional arguments to pass to the build process.
:param appname: str
The name of the application to build. It should correspond to an application defined in your project's
configuration.
:param additional_args: tuple
Additional arguments that can be passed to the build process for the specified application.
The `app` function loads the default project configuration, selects the specified application's build configuration,
and then executes the build process using the `_build` function.
Note:
- Ensure that the specified application name is valid and defined in your project's configuration.
- Additional arguments can be used to customize the build process for this specific application.
:return: None
- Ensure that the specified application name is valid and defined in your project's configuration.
- Additional arguments can be used to customize the build process for this specific application.
"""

conf = config.get_profile(profile)
Expand All @@ -212,22 +201,20 @@ def clean(target, profile):
This command is used to clean up build artifacts and files generated during the build process for one or more
specific applications. It allows you to specify a target application or clean all applications in the project.
:param target: str, default: ""
The name of the target application to clean. If not provided, it will clean all applications defined in your
project's configuration.
The `clean` command performs the following actions:
- If a specific 'target' is provided, it cleans the build artifacts for that application.
The `clean` command performs the following actions:
- If a specific 'target' is provided, it cleans the build artifacts for that application.
- If 'target' is not provided, it cleans the build artifacts for all applications defined in your project's
configuration.
- If 'target' is not provided, it cleans the build artifacts for all applications defined in your project's
configuration.
Note:
- When specifying a 'target,' ensure that it corresponds to a valid application defined in your project.
- Running the command without a 'target' will clean all applications.
:return: None
- When specifying a 'target,' ensure that it corresponds to a valid application defined in your project.
- Running the command without a 'target' will clean all applications.
"""

conf = config.get_profile(profile)

builds = conf.get("builds", {})
Expand Down
29 changes: 7 additions & 22 deletions src/viur_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import semver
import pprint


@click.group(invoke_without_command=True,
no_args_is_help=True,
context_settings={"help_option_names": ["-h", "--help"]})
Expand All @@ -16,26 +17,14 @@ def cli(ctx):
"""
Command-line interface for managing project configuration and information.
The viur-cli provides a set of commands to manage your project's configuration in the 'project.json'
if missing. It also offers commands to view and modify project information.
Usage:
```
viur [OPTIONS] COMMAND [ARGS]...
```
Options:
-h, --help Show this message and exit.
--version Show the CLI tool's version.
Commands:
project Manage project.json and generate if missing.
The viur-cli provides a set of commands to manage your project's configuration in the 'project.json'.
It also offers commands to view and modify project information.
Note:
- Use the `--version` option to display the CLI tool's version.
- Run the 'project' command to manage 'project.json' and project configuration settings.
:return: None
- Use the `--version` option to display the CLI tool's version.
- Run the 'project' command to manage 'project.json' and project configuration settings.
"""

# Get the systems pipenv Version Number
Expand All @@ -48,14 +37,11 @@ def cli(ctx):
if semver.compare(sys_pipenv, MINIMAL_PIPENV) < 0:
echo_warning(
f"Your pipenv Version does not match the recommended pipenv version. \n"
f"This mismatch may cause Errors, please consider to update your Systems pipenv version \n"
f"This mismatch may cause Errors, please consider updating your Systems pipenv version \n"
f"Your Version: {sys_pipenv}\n"
f"Recommended Version: {MINIMAL_PIPENV}"
)




@cli.command()
@click.argument("action", type=click.Choice(['list']))
@click.argument("profile", default="default")
Expand All @@ -65,4 +51,3 @@ def project(action, profile):
if action == "list":
echo_info(f"These are the Settings for {profile} profile")
pprint.pprint(project_config)

Loading

0 comments on commit adb5f3f

Please sign in to comment.