Project: CLight
Version: 2.4.3
OS: Microsoft / Windows
Author: Irakli Gzirishvili
Mail: [email protected]
CLight is a Python command-line interface application. A lightweight Framework that simplifies CLI app development and the package distribution process, with automatic deployment strategies from Local, GitHub and GitLab environments.
To use CLight, follow these steps:
- Open CMD as administrator and run the following command to install
pip install clight
then restart your CMD - To check if CLight is installed correctly, run the following command
clight
Runn CMD as administrator
These are the available commands you can use:
clight
- To list available commandsclight new
- Create new projectclight add
- Add existing project to catalogclight module (name)
- Create new moduleclight reform (-t)
- Edit project params, (-t) to skip templatesclight version
- Upgrade semantic version number of the projectclight all
- List existing projectsclight publish (-t)
- Publish project on PyPI, (-t) to test locallyclight remove (project)
- Remove projectclight pypidel
- Delete PyPI credentialsclight install
- Test the installation process locallyclight update
- Update local installation testclight uninstall
- Test the uninstallation process locally
It's easy to use this framework, just follow these simple steps:
- Navigate to your project's empty folder using CMD.
- Run
clight new
and fill out the simple CLI form. - Once you complete the details, CLight will automatically create a basic setup.
- Now, you can build CLI commands by simply creating methods in the
/.system/index.py
file. - To create a custom module, run
clight module <name>
and find it in the/.system/modules
folder. - To include some required pip modules for your project, specify them "only" in the
/.system/imports.py
file. - You can include other file resources in the
/.system/sources
folder.
By specifying the required pip modules in
/.system/imports.py
file just once - you automatically include them across the index file and your custom modules, so you don't need to make your modules ugly and separated.
In case you need to import a module with a specific version, comment it at the top of the /.system/imports.py
file like this: # import <module>==<major:minor:patch>
, then import it as it used to be imported. Here is the example:
from clight.system.importer import cli # DON'T REMOVE THIS LINE
# import openai==0:28
import os
import sys
import openai
...
In case you have to import a module with a different name than its importer hint, for example, in the case of soupsieve
, if you import it like this from bs4 import BeautifulSoup
, "bs4" is not a module and could not be processed for the installation of your project on other machines - You just need to add "soupsieve" as a commented line at the top of the file like this: # import soupsieve
and then add # !install
to the end of the actual import line like this: from bs4 import BeautifulSoup # !install
. Here is the example:
from clight.system.importer import cli # DON'T REMOVE THIS LINE
# import soupsieve
import os
import sys
from bs4 import BeautifulSoup # !install
...
Don't remove these items from the project's .system
folder:
- modules - Folder for your custom modules
- sources - Folder for system resources
- imports.py - File to import pip and your custom packages
- index.py - Index file, defining the main CLI commands that users will interact with
The index and module files are constructed with 3 sections of code:
- Load - Section for initializing your project and running some scripts before executing required command
- Main - CLI command methods with name, arguments and description
- Helpers - Private methods used to support the Main methods
You don't need anything else, this is the simplest CLI application framework interface to save your time
These are basic methods from the clight
package class called cli
that you can use in your index and module files:
cli.error("message")
- Print an error message in redcli.info("message")
- Print an info message in bluecli.hint("message")
- Print a hint in yellowcli.done("message")
- Print a completion message in greencli.trace("message")
- Print hidden developer message, activate dev mode withcli.dev = True
cli.input("hint")
- Define CLI input fieldcli.selection("hint", ["A", "B"])
- Define selection input fieldcli.selections("hint", ["A", "B"])
- Define multiple selection input fieldcli.confirmation("hint")
- Define confirmation input fieldcli.value("key", {...}, "default")
- Get value from datacli.sound("done")
- Set system sound - start, ready, done, error, ask, set or unsetcli.speak("text")
- Read text with voicecli.listen()
- Listen and convert speech to textcli.read("Folder/file.txt")
- Read file and get contentcli.write("Folder/file.txt", "content")
- Write file with contentcli.append("Folder/file.txt", "content")
- Append content to the filecli.yaml("Folder/file.yaml")
- Read and convert YAML file as dictcli.template("content", {...})
- Parse template content with given key-value pairscli.chars(10)
- Get random characters with given lengthcli.isValue(value)
- Check if value existscli.isPath(path)
- Check if path existscli.isFile(file)
- Check if file existscli.isFolder(folder)
- Check if folder existscli.command("cmd line")
- Execute CMD commandcli.encrypt("data", "key")
- Encrypt data by keycli.decrypt("encrypted", "key")
- Decrypt encrypted data by keycli.filter("text")
- Filter user text before printing
When creating your new project, you will be asked to fill a simple form just once, to specify your project's configuration parameters:
- Name - Name of your project
required
- Version - Version of your project
required
- Description - Description of your project
required
- Link - Link to your project
- CMD - CMD name alias for your project
required
- Author - Author of the project
required
- Mail - Mail of the project author
required
- Project Type - Type of the project
required
- Repository Type - Project repository type
required
- License - License for your project
- Operating System - Required operating system for your project
required
Project Type: Select
App
to develop a new CLI application, or selectModule
to develop a single pip module
At this stage, CLight works with 3 types of project repository environments:
- Local - Publishing projects from your local development Windows environment to PyPI
- GitHub - Automated deployment process to PyPI once you push changes to the main branch
- GitLab - Automated deployment process to PyPI once you push changes to the main branch
PyPI is the official third-party package repository for the Python programming language. It hosts and distributes software packages for developers to use. Developers can upload Python packages to PyPI, where they can be easily accessed by others. Anyone can then download them using the
pip install <package>
command
When creating a project with CLight, you can include one of the 8 OSI-Approved license types:
- MIT License
- BSD License
- ISC License (ISCL)
- Apache Software License
- Mozilla Public License 2.0 (MPL 2.0)
- GNU Affero General Public License v3
- GNU General Public License v3 (GPLv3)
- GNU Lesser General Public License v3 (LGPLv3)
When creating a project with CLight, you should specify the OS environment for your project:
- OS Independent
- Microsoft / Windows
- POSIX / Linux
- MacOS
Before publishing your updated project, according to PyPI rules, you must increase your project's version number:
Navigate to your project's root directory using CMD, run clight version
and select type option of the changes.
CLight will automatically increase the version number based on your selected option.
Based on your selected Repository Type, the project will be deployed to PyPI in the following ways:
-
Local - Publishing projects from your local development Windows environment to PyPI
- Navigate to your project's root directory using CMD and run
clight publish
- If this is your first time, provide your PyPI
PYPI_USERNAME
andPYPI_API_TOKEN
- Then choose whether to save your credentials or not
- If you choose to save your credentials, provide a
Password Key
to encrypt them - That's it. The next time, you will just be asked for the Password Key
- Navigate to your project's root directory using CMD and run
-
GitHub - Automated deployment process to PyPI once you push changes to the main branch
- Nothing to do, just push the changes
-
GitLab - Automated deployment process to PyPI once you push changes to the main branch
- Nothing to do, just push the changes
Note: You must add PyPI credentials as repository secure variables in GitHub and GitLab with these names:
PYPI_USERNAME
andPYPI_API_TOKEN