fix: Rename freeflowuniverse to incubaid
This commit is contained in:
@@ -24,7 +24,7 @@ Thank you for your interest in contributing to Herolib! This document provides g
|
|||||||
For developers, you can use the automated installation script:
|
For developers, you can use the automated installation script:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl 'https://raw.githubusercontent.com/freeflowuniverse/herolib/refs/heads/development/install_v.sh' > /tmp/install_v.sh
|
curl 'https://raw.githubusercontent.com/incubaid/herolib/refs/heads/development/install_v.sh' > /tmp/install_v.sh
|
||||||
bash /tmp/install_v.sh --analyzer --herolib
|
bash /tmp/install_v.sh --analyzer --herolib
|
||||||
# IMPORTANT: Start a new shell after installation for paths to be set correctly
|
# IMPORTANT: Start a new shell after installation for paths to be set correctly
|
||||||
```
|
```
|
||||||
@@ -34,7 +34,7 @@ Alternatively, you can manually set up the environment:
|
|||||||
```bash
|
```bash
|
||||||
mkdir -p ~/code/github/incubaid
|
mkdir -p ~/code/github/incubaid
|
||||||
cd ~/code/github/incubaid
|
cd ~/code/github/incubaid
|
||||||
git clone git@github.com:freeflowuniverse/herolib.git
|
git clone git@github.com:incubaid/herolib.git
|
||||||
cd herolib
|
cd herolib
|
||||||
# checkout development branch for most recent changes
|
# checkout development branch for most recent changes
|
||||||
git checkout development
|
git checkout development
|
||||||
@@ -63,6 +63,7 @@ For new features or bug fixes, create a branch from `development` with a descrip
|
|||||||
### Making Changes
|
### Making Changes
|
||||||
|
|
||||||
1. Create a new branch from `development`:
|
1. Create a new branch from `development`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git checkout development
|
git checkout development
|
||||||
git pull
|
git pull
|
||||||
@@ -72,6 +73,7 @@ For new features or bug fixes, create a branch from `development` with a descrip
|
|||||||
2. Make your changes, following the code guidelines.
|
2. Make your changes, following the code guidelines.
|
||||||
|
|
||||||
3. Run tests to ensure your changes don't break existing functionality:
|
3. Run tests to ensure your changes don't break existing functionality:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./test_basic.vsh
|
./test_basic.vsh
|
||||||
```
|
```
|
||||||
@@ -98,6 +100,7 @@ The test script (`test_basic.vsh`) manages test execution and caching to optimiz
|
|||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
||||||
1. Push your branch to the repository:
|
1. Push your branch to the repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git push origin feature/your-feature-name
|
git push origin feature/your-feature-name
|
||||||
```
|
```
|
||||||
@@ -125,6 +128,7 @@ The repository uses GitHub Actions for continuous integration and deployment:
|
|||||||
### 1. Testing Workflow (`test.yml`)
|
### 1. Testing Workflow (`test.yml`)
|
||||||
|
|
||||||
This workflow runs on every push and pull request to ensure code quality:
|
This workflow runs on every push and pull request to ensure code quality:
|
||||||
|
|
||||||
- Sets up V and Herolib
|
- Sets up V and Herolib
|
||||||
- Runs all basic tests using `test_basic.vsh`
|
- Runs all basic tests using `test_basic.vsh`
|
||||||
|
|
||||||
@@ -133,6 +137,7 @@ All tests must pass before a PR can be merged to the `development` branch.
|
|||||||
### 2. Hero Build Workflow (`hero_build.yml`)
|
### 2. Hero Build Workflow (`hero_build.yml`)
|
||||||
|
|
||||||
This workflow builds the Hero tool for multiple platforms when a new tag is created:
|
This workflow builds the Hero tool for multiple platforms when a new tag is created:
|
||||||
|
|
||||||
- Builds for Linux (x86_64, aarch64) and macOS (x86_64, aarch64)
|
- Builds for Linux (x86_64, aarch64) and macOS (x86_64, aarch64)
|
||||||
- Runs all basic tests
|
- Runs all basic tests
|
||||||
- Creates GitHub releases with the built binaries
|
- Creates GitHub releases with the built binaries
|
||||||
@@ -140,6 +145,7 @@ This workflow builds the Hero tool for multiple platforms when a new tag is crea
|
|||||||
### 3. Documentation Workflow (`documentation.yml`)
|
### 3. Documentation Workflow (`documentation.yml`)
|
||||||
|
|
||||||
This workflow automatically updates the documentation on GitHub Pages when changes are pushed to the `development` branch:
|
This workflow automatically updates the documentation on GitHub Pages when changes are pushed to the `development` branch:
|
||||||
|
|
||||||
- Generates documentation using `doc.vsh`
|
- Generates documentation using `doc.vsh`
|
||||||
- Deploys the documentation to GitHub Pages
|
- Deploys the documentation to GitHub Pages
|
||||||
|
|
||||||
@@ -152,7 +158,7 @@ cd ~/code/github/incubaid/herolib
|
|||||||
bash doc.sh
|
bash doc.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
The documentation is automatically published to [https://freeflowuniverse.github.io/herolib/](https://freeflowuniverse.github.io/herolib/) when changes are pushed to the `development` branch.
|
The documentation is automatically published to [https://incubaid.github.io/herolib/](https://incubaid.github.io/herolib/) when changes are pushed to the `development` branch.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
@@ -168,6 +174,7 @@ In file included from /Users/timurgordon/code/github/vlang/v/thirdparty/cJSON/cJ
|
|||||||
This is caused by incompatibility between TCC and the half precision math functions in the macOS SDK. To fix this issue:
|
This is caused by incompatibility between TCC and the half precision math functions in the macOS SDK. To fix this issue:
|
||||||
|
|
||||||
1. Open the math.h file:
|
1. Open the math.h file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo nano /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h
|
sudo nano /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h
|
||||||
```
|
```
|
||||||
@@ -178,6 +185,6 @@ For more details, see the [README.md](README.md) troubleshooting section.
|
|||||||
|
|
||||||
## Additional Resources
|
## Additional Resources
|
||||||
|
|
||||||
- [Herolib Documentation](https://freeflowuniverse.github.io/herolib/)
|
- [Herolib Documentation](https://incubaid.github.io/herolib/)
|
||||||
- [Cookbook Examples](https://github.com/freeflowuniverse/herolib/tree/development/cookbook)
|
- [Cookbook Examples](https://github.com/incubaid/herolib/tree/development/cookbook)
|
||||||
- [AI Prompts](aiprompts/starter/0_start_here.md)
|
- [AI Prompts](aiprompts/starter/0_start_here.md)
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -5,7 +5,7 @@ Herolib is an opinionated library primarily used by ThreeFold to automate cloud
|
|||||||
[](https://github.com/incubaid/herolib/actions/workflows/test.yml)
|
[](https://github.com/incubaid/herolib/actions/workflows/test.yml)
|
||||||
[](https://github.com/incubaid/herolib/actions/workflows/documentation.yml)
|
[](https://github.com/incubaid/herolib/actions/workflows/documentation.yml)
|
||||||
|
|
||||||
> [Complete Documentation](https://freeflowuniverse.github.io/herolib/)
|
> [Complete Documentation](https://incubaid.github.io/herolib/)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ curl https://raw.githubusercontent.com/incubaid/herolib/refs/heads/development/i
|
|||||||
```
|
```
|
||||||
|
|
||||||
Hero will be installed in:
|
Hero will be installed in:
|
||||||
|
|
||||||
- `/usr/local/bin` for Linux
|
- `/usr/local/bin` for Linux
|
||||||
- `~/hero/bin` for macOS
|
- `~/hero/bin` for macOS
|
||||||
|
|
||||||
@@ -74,15 +75,16 @@ Herolib provides a wide range of functionality:
|
|||||||
|
|
||||||
- Cloud automation tools
|
- Cloud automation tools
|
||||||
- Git operations and management
|
- Git operations and management
|
||||||
|
|
||||||
### Offline Mode for Git Operations
|
### Offline Mode for Git Operations
|
||||||
|
|
||||||
Herolib now supports an `offline` mode for Git operations, which prevents automatic fetching from remote repositories. This can be useful in environments with limited or no internet connectivity, or when you want to avoid network calls during development or testing.
|
Herolib now supports an `offline` mode for Git operations, which prevents automatic fetching from remote repositories. This can be useful in environments with limited or no internet connectivity, or when you want to avoid network calls during development or testing.
|
||||||
|
|
||||||
To enable offline mode:
|
To enable offline mode:
|
||||||
|
|
||||||
- **Via `GitStructureConfig`**: Set the `offline` field to `true` in the `GitStructureConfig` struct.
|
- **Via `GitStructureConfig`**: Set the `offline` field to `true` in the `GitStructureConfig` struct.
|
||||||
- **Via `GitStructureArgsNew`**: When creating a new `GitStructure` instance using `gittools.new()`, set the `offline` parameter to `true`.
|
- **Via `GitStructureArgsNew`**: When creating a new `GitStructure` instance using `gittools.new()`, set the `offline` parameter to `true`.
|
||||||
- **Via Environment Variable**: Set the `OFFLINE` environment variable to any value (e.g., `export OFFLINE=true`).
|
- **Via Environment Variable**: Set the `OFFLINE` environment variable to any value (e.g., `export OFFLINE=true`).
|
||||||
|
|
||||||
When offline mode is active, `git fetch --all` operations will be skipped, and a debug message "fetch skipped (offline)" will be printed.
|
When offline mode is active, `git fetch --all` operations will be skipped, and a debug message "fetch skipped (offline)" will be printed.
|
||||||
- Documentation building
|
- Documentation building
|
||||||
@@ -133,11 +135,13 @@ In file included from /Users/timurgordon/code/github/vlang/v/thirdparty/cJSON/cJ
|
|||||||
This is caused by incompatibility between TCC and the half precision math functions in the macOS SDK. To fix this issue:
|
This is caused by incompatibility between TCC and the half precision math functions in the macOS SDK. To fix this issue:
|
||||||
|
|
||||||
1. Open the math.h file:
|
1. Open the math.h file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo nano /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h
|
sudo nano /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Comment out the following lines (around line 612-626):
|
2. Comment out the following lines (around line 612-626):
|
||||||
|
|
||||||
```c
|
```c
|
||||||
/* half precision math functions */
|
/* half precision math functions */
|
||||||
// extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
|
// extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
|
||||||
@@ -159,7 +163,7 @@ This is caused by incompatibility between TCC and the half precision math functi
|
|||||||
|
|
||||||
## Additional Resources
|
## Additional Resources
|
||||||
|
|
||||||
- [Complete Documentation](https://freeflowuniverse.github.io/herolib/)
|
- [Complete Documentation](https://incubaid.github.io/herolib/)
|
||||||
- [Cookbook Examples](https://github.com/incubaid/herolib/tree/development/cookbook)
|
- [Cookbook Examples](https://github.com/incubaid/herolib/tree/development/cookbook)
|
||||||
- [AI Prompts](aiprompts/starter/0_start_here.md)
|
- [AI Prompts](aiprompts/starter/0_start_here.md)
|
||||||
|
|
||||||
@@ -172,7 +176,6 @@ cd ~/code/github/incubaid/herolib
|
|||||||
bash doc.sh
|
bash doc.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
<!-- Security scan triggered at 2025-09-02 01:58:41 -->
|
<!-- Security scan triggered at 2025-09-02 01:58:41 -->
|
||||||
|
|
||||||
<!-- Security scan triggered at 2025-09-09 05:33:18 -->
|
<!-- Security scan triggered at 2025-09-09 05:33:18 -->
|
||||||
@@ -43,8 +43,6 @@ follow rows in sheets
|
|||||||
- cogs_item_monthly_rev_perc: what is percentage of the monthly revenue which is cogs, e.g. 10%
|
- cogs_item_monthly_rev_perc: what is percentage of the monthly revenue which is cogs, e.g. 10%
|
||||||
- cogs_item_delay, how many months before cogs starts after sales
|
- cogs_item_delay, how many months before cogs starts after sales
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### results in
|
### results in
|
||||||
|
|
||||||
follow rows in sheets
|
follow rows in sheets
|
||||||
@@ -62,7 +60,7 @@ follow rows in sheets
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript:="
|
heroscript:="
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ This manual provides a comprehensive guide on how to leverage HeroLib's Docusaur
|
|||||||
|
|
||||||
To effectively create ebooks with HeroLib, it's crucial to understand the interplay of three core components:
|
To effectively create ebooks with HeroLib, it's crucial to understand the interplay of three core components:
|
||||||
|
|
||||||
* **HeroScript**: A concise scripting language used to define the structure, configuration, and content flow of your Docusaurus site. It acts as the declarative interface for the entire process.
|
* **HeroScript**: A concise scripting language used to define the structure, configuration, and content flow of your Docusaurus site. It acts as the declarative interface for the entire process.
|
||||||
* **Docusaurus**: A popular open-source static site generator. HeroLib uses Docusaurus as the underlying framework to render your ebook content into a navigable website.
|
* **Docusaurus**: A popular open-source static site generator. HeroLib uses Docusaurus as the underlying framework to render your ebook content into a navigable website.
|
||||||
* **Doctree**: HeroLib's content management system. Doctree organizes your markdown files into "collections" and "pages," allowing for structured content retrieval and reuse across multiple projects.
|
* **Doctree**: HeroLib's content management system. Doctree organizes your markdown files into "collections" and "pages," allowing for structured content retrieval and reuse across multiple projects.
|
||||||
|
|
||||||
## 2. Setting Up a Docusaurus Project with HeroLib
|
## 2. Setting Up a Docusaurus Project with HeroLib
|
||||||
|
|
||||||
@@ -30,10 +30,10 @@ The `docusaurus.define` HeroScript directive configures the global settings for
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* `path_build` (string, optional): The local path where the Docusaurus site will be built. Defaults to `~/hero/var/docusaurus/build`.
|
* `path_build` (string, optional): The local path where the Docusaurus site will be built. Defaults to `~/hero/var/docusaurus/build`.
|
||||||
* `path_publish` (string, optional): The local path where the final Docusaurus site will be published (e.g., for deployment). Defaults to `~/hero/var/docusaurus/publish`.
|
* `path_publish` (string, optional): The local path where the final Docusaurus site will be published (e.g., for deployment). Defaults to `~/hero/var/docusaurus/publish`.
|
||||||
* `production` (boolean, optional): If `true`, the site will be built for production (optimized). Default is `false`.
|
* `production` (boolean, optional): If `true`, the site will be built for production (optimized). Default is `false`.
|
||||||
* `update` (boolean, optional): If `true`, the Docusaurus template and dependencies will be updated. Default is `false`.
|
* `update` (boolean, optional): If `true`, the Docusaurus template and dependencies will be updated. Default is `false`.
|
||||||
|
|
||||||
### 2.2. Adding a Docusaurus Site (`docusaurus.add`)
|
### 2.2. Adding a Docusaurus Site (`docusaurus.add`)
|
||||||
|
|
||||||
@@ -61,19 +61,19 @@ The `docusaurus.add` directive defines an individual Docusaurus site (your ebook
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* `name` (string, optional): A unique name for your Docusaurus site/ebook. Defaults to "main".
|
* `name` (string, optional): A unique name for your Docusaurus site/ebook. Defaults to "main".
|
||||||
* `path` (string, optional): The local file system path to the root of your documentation content (e.g., where your `docs` and `cfg` directories are).
|
* `path` (string, optional): The local file system path to the root of your documentation content (e.g., where your `docs` and `cfg` directories are).
|
||||||
* `git_url` (string, optional): A Git URL to a repository containing your documentation content. HeroLib will clone/pull this repository.
|
* `git_url` (string, optional): A Git URL to a repository containing your documentation content. HeroLib will clone/pull this repository.
|
||||||
* `git_reset` (boolean, optional): If `true`, the Git repository will be reset to a clean state before pulling. Default is `false`.
|
* `git_reset` (boolean, optional): If `true`, the Git repository will be reset to a clean state before pulling. Default is `false`.
|
||||||
* `git_pull` (boolean, optional): If `true`, the Git repository will be pulled to get the latest changes. Default is `false`.
|
* `git_pull` (boolean, optional): If `true`, the Git repository will be pulled to get the latest changes. Default is `false`.
|
||||||
* `git_root` (string, optional): An optional root directory where Git repositories will be cloned.
|
* `git_root` (string, optional): An optional root directory where Git repositories will be cloned.
|
||||||
* `nameshort` (string, optional): A shorter name for the Docusaurus site. Defaults to the value of `name`.
|
* `nameshort` (string, optional): A shorter name for the Docusaurus site. Defaults to the value of `name`.
|
||||||
* `path_publish` (string, optional): Overrides the factory's `path_publish` for this specific site.
|
* `path_publish` (string, optional): Overrides the factory's `path_publish` for this specific site.
|
||||||
* `production` (boolean, optional): Overrides the factory's `production` setting for this specific site.
|
* `production` (boolean, optional): Overrides the factory's `production` setting for this specific site.
|
||||||
* `watch_changes` (boolean, optional): If `true`, HeroLib will watch for changes in your source `docs` directory and trigger rebuilds. Default is `true`.
|
* `watch_changes` (boolean, optional): If `true`, HeroLib will watch for changes in your source `docs` directory and trigger rebuilds. Default is `true`.
|
||||||
* `update` (boolean, optional): If `true`, this specific documentation will be updated. Default is `false`.
|
* `update` (boolean, optional): If `true`, this specific documentation will be updated. Default is `false`.
|
||||||
* `open` (boolean, optional): If `true`, the Docusaurus site will be opened in your default browser after generation/development server start. Default is `false`.
|
* `open` (boolean, optional): If `true`, the Docusaurus site will be opened in your default browser after generation/development server start. Default is `false`.
|
||||||
* `init` (boolean, optional): If `true`, the Docusaurus site will be initialized (e.g., creating missing `docs` directories). Default is `false`.
|
* `init` (boolean, optional): If `true`, the Docusaurus site will be initialized (e.g., creating missing `docs` directories). Default is `false`.
|
||||||
|
|
||||||
## 3. Structuring Content with HeroScript and Doctree
|
## 3. Structuring Content with HeroScript and Doctree
|
||||||
|
|
||||||
@@ -105,22 +105,22 @@ These directives define the fundamental properties and metadata of your Docusaur
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* **`site.config`**:
|
* **`site.config`**:
|
||||||
* `name` (string, required): Unique identifier for the site.
|
* `name` (string, required): Unique identifier for the site.
|
||||||
* `title` (string, optional): Main title of the site. Defaults to "My Documentation Site".
|
* `title` (string, optional): Main title of the site. Defaults to "My Documentation Site".
|
||||||
* `description` (string, optional): General site description.
|
* `description` (string, optional): General site description.
|
||||||
* `tagline` (string, optional): Short tagline for the site.
|
* `tagline` (string, optional): Short tagline for the site.
|
||||||
* `favicon` (string, optional): Path to the favicon. Defaults to "img/favicon.png".
|
* `favicon` (string, optional): Path to the favicon. Defaults to "img/favicon.png".
|
||||||
* `image` (string, optional): General site image (e.g., for social media previews). Defaults to "img/tf_graph.png".
|
* `image` (string, optional): General site image (e.g., for social media previews). Defaults to "img/tf_graph.png".
|
||||||
* `copyright` (string, optional): Copyright notice. Defaults to "© [Current Year] Example Organization".
|
* `copyright` (string, optional): Copyright notice. Defaults to "© [Current Year] Example Organization".
|
||||||
* `url` (string, optional): The main URL where the site will be hosted.
|
* `url` (string, optional): The main URL where the site will be hosted.
|
||||||
* `base_url` (string, optional): The base URL for Docusaurus (e.g., `/` or `/my-ebook/`).
|
* `base_url` (string, optional): The base URL for Docusaurus (e.g., `/` or `/my-ebook/`).
|
||||||
* `url_home` (string, optional): The path to the home page relative to `base_url`.
|
* `url_home` (string, optional): The path to the home page relative to `base_url`.
|
||||||
* **`site.config_meta`**: Overrides for specific SEO metadata.
|
* **`site.config_meta`**: Overrides for specific SEO metadata.
|
||||||
* `title` (string, optional): Specific title for SEO (e.g., `<meta property="og:title">`).
|
* `title` (string, optional): Specific title for SEO (e.g., `<meta property="og:title">`).
|
||||||
* `image` (string, optional): Specific image for SEO (e.g., `<meta property="og:image">`).
|
* `image` (string, optional): Specific image for SEO (e.g., `<meta property="og:image">`).
|
||||||
* `description` (string, optional): Specific description for SEO.
|
* `description` (string, optional): Specific description for SEO.
|
||||||
* `keywords` (string, optional): Comma-separated keywords for SEO.
|
* `keywords` (string, optional): Comma-separated keywords for SEO.
|
||||||
|
|
||||||
### 3.2. Navigation Bar (`site.navbar`, `site.navbar_item`)
|
### 3.2. Navigation Bar (`site.navbar`, `site.navbar_item`)
|
||||||
|
|
||||||
@@ -148,16 +148,16 @@ Define the main navigation menu of your Docusaurus site.
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* **`site.navbar`**:
|
* **`site.navbar`**:
|
||||||
* `title` (string, optional): Title displayed in the navbar. Defaults to `site.config.title`.
|
* `title` (string, optional): Title displayed in the navbar. Defaults to `site.config.title`.
|
||||||
* `logo_alt` (string, optional): Alt text for the logo.
|
* `logo_alt` (string, optional): Alt text for the logo.
|
||||||
* `logo_src` (string, optional): Path to the light mode logo.
|
* `logo_src` (string, optional): Path to the light mode logo.
|
||||||
* `logo_src_dark` (string, optional): Path to the dark mode logo.
|
* `logo_src_dark` (string, optional): Path to the dark mode logo.
|
||||||
* **`site.navbar_item`**:
|
* **`site.navbar_item`**:
|
||||||
* `label` (string, required): Text displayed for the menu item.
|
* `label` (string, required): Text displayed for the menu item.
|
||||||
* `href` (string, optional): External URL for the link.
|
* `href` (string, optional): External URL for the link.
|
||||||
* `to` (string, optional): Internal Docusaurus path (e.g., `/docs/my-page`).
|
* `to` (string, optional): Internal Docusaurus path (e.g., `/docs/my-page`).
|
||||||
* `position` (string, optional): "left" or "right" for placement in the navbar. Defaults to "right".
|
* `position` (string, optional): "left" or "right" for placement in the navbar. Defaults to "right".
|
||||||
|
|
||||||
### 3.3. Footer (`site.footer`, `site.footer_item`)
|
### 3.3. Footer (`site.footer`, `site.footer_item`)
|
||||||
|
|
||||||
@@ -182,13 +182,13 @@ Configure the footer section of your Docusaurus site.
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* **`site.footer`**:
|
* **`site.footer`**:
|
||||||
* `style` (string, optional): "dark" or "light" style for the footer. Defaults to "dark".
|
* `style` (string, optional): "dark" or "light" style for the footer. Defaults to "dark".
|
||||||
* **`site.footer_item`**:
|
* **`site.footer_item`**:
|
||||||
* `title` (string, required): The title under which this item will be grouped in the footer.
|
* `title` (string, required): The title under which this item will be grouped in the footer.
|
||||||
* `label` (string, required): Text displayed for the footer link.
|
* `label` (string, required): Text displayed for the footer link.
|
||||||
* `href` (string, optional): External URL for the link.
|
* `href` (string, optional): External URL for the link.
|
||||||
* `to` (string, optional): Internal Docusaurus path.
|
* `to` (string, optional): Internal Docusaurus path.
|
||||||
|
|
||||||
### 3.4. Build Destinations (`site.build_dest`, `site.build_dest_dev`)
|
### 3.4. Build Destinations (`site.build_dest`, `site.build_dest_dev`)
|
||||||
|
|
||||||
@@ -208,8 +208,8 @@ Specify where the built Docusaurus site should be deployed. This typically invol
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* `ssh_name` (string, required): The name of the SSH connection to use for deployment.
|
* `ssh_name` (string, required): The name of the SSH connection to use for deployment.
|
||||||
* `path` (string, required): The destination path on the remote server.
|
* `path` (string, required): The destination path on the remote server.
|
||||||
|
|
||||||
### 3.5. Importing External Content (`site.import`)
|
### 3.5. Importing External Content (`site.import`)
|
||||||
|
|
||||||
@@ -226,9 +226,9 @@ This powerful feature allows you to pull markdown content and assets from other
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* `url` (string, required): The Git URL of the repository or specific path within a repository to import.
|
* `url` (string, required): The Git URL of the repository or specific path within a repository to import.
|
||||||
* `dest` (string, required): The subdirectory within your Docusaurus `docs` folder where the imported content will be placed.
|
* `dest` (string, required): The subdirectory within your Docusaurus `docs` folder where the imported content will be placed.
|
||||||
* `replace` (string, optional): A comma-separated string of `KEY:VALUE` pairs. During import, all occurrences of `${KEY}` in the imported content will be replaced with `VALUE`.
|
* `replace` (string, optional): A comma-separated string of `KEY:VALUE` pairs. During import, all occurrences of `${KEY}` in the imported content will be replaced with `VALUE`.
|
||||||
|
|
||||||
### 3.6. Defining Pages and Categories (`site.page_category`, `site.page`)
|
### 3.6. Defining Pages and Categories (`site.page_category`, `site.page`)
|
||||||
|
|
||||||
@@ -250,20 +250,20 @@ This is where you define the actual content pages and how they are organized int
|
|||||||
|
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
|
|
||||||
* **`site.page_category`**:
|
* **`site.page_category`**:
|
||||||
* `path` (string, required): The path to the category directory within your Docusaurus `docs` folder (e.g., `introduction` will create `docs/introduction/_category_.json`).
|
* `path` (string, required): The path to the category directory within your Docusaurus `docs` folder (e.g., `introduction` will create `docs/introduction/_category_.json`).
|
||||||
* `label` (string, required): The display name for the category in the sidebar.
|
* `label` (string, required): The display name for the category in the sidebar.
|
||||||
* `position` (int, optional): The order of the category in the sidebar.
|
* `position` (int, optional): The order of the category in the sidebar.
|
||||||
* `sitename` (string, optional): If you have multiple Docusaurus sites defined, specify which site this category belongs to. Defaults to the current site's name.
|
* `sitename` (string, optional): If you have multiple Docusaurus sites defined, specify which site this category belongs to. Defaults to the current site's name.
|
||||||
* **`site.page`**:
|
* **`site.page`**:
|
||||||
* `src` (string, required): **Crucial for Doctree integration.** This specifies the source of the page content in the format `collection_name:page_name`. HeroLib will fetch the markdown content from the specified Doctree collection and page.
|
* `src` (string, required): **Crucial for Doctree integration.** This specifies the source of the page content in the format `collection_name:page_name`. HeroLib will fetch the markdown content from the specified Doctree collection and page.
|
||||||
* `path` (string, required): The relative path and filename for the generated markdown file within your Docusaurus `docs` folder (e.g., `introduction/chapter_1.md`). If only a directory is provided (e.g., `introduction/`), the `page_name` from `src` will be used as the filename.
|
* `path` (string, required): The relative path and filename for the generated markdown file within your Docusaurus `docs` folder (e.g., `introduction/chapter_1.md`). If only a directory is provided (e.g., `introduction/`), the `page_name` from `src` will be used as the filename.
|
||||||
* `title` (string, optional): The title of the page. If not provided, HeroLib will attempt to extract it from the markdown content or use the `page_name`.
|
* `title` (string, optional): The title of the page. If not provided, HeroLib will attempt to extract it from the markdown content or use the `page_name`.
|
||||||
* `description` (string, optional): A short description for the page, used in frontmatter.
|
* `description` (string, optional): A short description for the page, used in frontmatter.
|
||||||
* `position` (int, optional): The order of the page within its category.
|
* `position` (int, optional): The order of the page within its category.
|
||||||
* `hide_title` (boolean, optional): If `true`, the title will not be displayed on the page itself.
|
* `hide_title` (boolean, optional): If `true`, the title will not be displayed on the page itself.
|
||||||
* `draft` (boolean, optional): If `true`, the page will be marked as a draft and not included in production builds.
|
* `draft` (boolean, optional): If `true`, the page will be marked as a draft and not included in production builds.
|
||||||
* `title_nr` (int, optional): If set, HeroLib will re-number the markdown headings (e.g., `title_nr:3` will make `# Heading` become `### Heading`). Useful for consistent heading levels across imported content.
|
* `title_nr` (int, optional): If set, HeroLib will re-number the markdown headings (e.g., `title_nr:3` will make `# Heading` become `### Heading`). Useful for consistent heading levels across imported content.
|
||||||
|
|
||||||
### 3.7. Doctree Integration Details
|
### 3.7. Doctree Integration Details
|
||||||
|
|
||||||
@@ -271,14 +271,16 @@ The `site.page` directive's `src` parameter (`collection_name:page_name`) is the
|
|||||||
|
|
||||||
**How Doctree Works:**
|
**How Doctree Works:**
|
||||||
|
|
||||||
1. **Collections**: Doctree organizes markdown files into logical groups called "collections." A collection is typically a directory containing markdown files and an empty `.collection` file.
|
1. **Collections**: Doctree organizes markdown files into logical groups called "collections." A collection is typically a directory containing markdown files and an empty `.collection` file.
|
||||||
2. **Scanning**: You define which collections Doctree should scan using `!!doctree.scan` in a HeroScript file (e.g., `doctree.heroscript`).
|
2. **Scanning**: You define which collections Doctree should scan using `!!doctree.scan` in a HeroScript file (e.g., `doctree.heroscript`).
|
||||||
**Example `doctree.heroscript`:**
|
**Example `doctree.heroscript`:**
|
||||||
|
|
||||||
```heroscript
|
```heroscript
|
||||||
!!doctree.scan git_url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/collections"
|
!!doctree.scan git_url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/collections"
|
||||||
```
|
```
|
||||||
|
|
||||||
This will pull the `collections` directory from the specified Git URL and make its contents available to Doctree.
|
This will pull the `collections` directory from the specified Git URL and make its contents available to Doctree.
|
||||||
3. **Page Retrieval**: When `site.page` references `src:"my_collection:my_page"`, HeroLib's `doctreeclient` fetches the content of `my_page.md` from the `my_collection` collection that Doctree has scanned.
|
3. **Page Retrieval**: When `site.page` references `src:"my_collection:my_page"`, HeroLib's `doctreeclient` fetches the content of `my_page.md` from the `my_collection` collection that Doctree has scanned.
|
||||||
|
|
||||||
## 4. Building and Developing Your Ebook
|
## 4. Building and Developing Your Ebook
|
||||||
|
|
||||||
@@ -287,12 +289,13 @@ Once your HeroScript configuration is set up, HeroLib provides commands to build
|
|||||||
### 4.1. Generating Site Files (`site.generate()`)
|
### 4.1. Generating Site Files (`site.generate()`)
|
||||||
|
|
||||||
The `site.generate()` function (called internally by `build`, `dev`, etc.) performs the core file generation:
|
The `site.generate()` function (called internally by `build`, `dev`, etc.) performs the core file generation:
|
||||||
* Copies Docusaurus template files.
|
|
||||||
* Copies your site's `src` and `static` assets.
|
* Copies Docusaurus template files.
|
||||||
* Generates Docusaurus configuration JSON files (`main.json`, `navbar.json`, `footer.json`) from your HeroScript `site.config`, `site.navbar`, and `site.footer` directives.
|
* Copies your site's `src` and `static` assets.
|
||||||
* Copies your source `docs` directory.
|
* Generates Docusaurus configuration JSON files (`main.json`, `navbar.json`, `footer.json`) from your HeroScript `site.config`, `site.navbar`, and `site.footer` directives.
|
||||||
* Processes `site.page` and `site.page_category` directives using the `sitegen` module to create the final markdown files and `_category_.json` files in the Docusaurus `docs` directory, fetching content from Doctree.
|
* Copies your source `docs` directory.
|
||||||
* Handles `site.import` directives, pulling external content and performing replacements.
|
* Processes `site.page` and `site.page_category` directives using the `sitegen` module to create the final markdown files and `_category_.json` files in the Docusaurus `docs` directory, fetching content from Doctree.
|
||||||
|
* Handles `site.import` directives, pulling external content and performing replacements.
|
||||||
|
|
||||||
### 4.2. Local Development
|
### 4.2. Local Development
|
||||||
|
|
||||||
@@ -305,35 +308,34 @@ can be stored as example_docusaurus.vsh and then used to generate and develop an
|
|||||||
```v
|
```v
|
||||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.web.docusaurus
|
import incubaid.herolib.web.docusaurus
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const cfgpath = os.dir(@FILE)
|
const cfgpath = os.dir(@FILE)
|
||||||
|
|
||||||
docusaurus.new(
|
docusaurus.new(
|
||||||
heroscript: '
|
heroscript: '
|
||||||
|
|
||||||
// !!docusaurus.define
|
// !!docusaurus.define
|
||||||
// path_build: "/tmp/docusaurus_build"
|
// path_build: "/tmp/docusaurus_build"
|
||||||
// path_publish: "/tmp/docusaurus_publish"
|
// path_publish: "/tmp/docusaurus_publish"
|
||||||
|
|
||||||
!!docusaurus.add name:"tfgrid_docs"
|
!!docusaurus.add name:"tfgrid_docs"
|
||||||
path:"${cfgpath}"
|
path:"${cfgpath}"
|
||||||
|
|
||||||
!!docusaurus.dev
|
!!docusaurus.dev
|
||||||
|
|
||||||
'
|
'
|
||||||
)!
|
)!
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
the following script suggest to call it do.vsh and put in directory of where the ebook is
|
the following script suggest to call it do.vsh and put in directory of where the ebook is
|
||||||
|
|
||||||
```v
|
```v
|
||||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.web.docusaurus
|
import incubaid.herolib.web.docusaurus
|
||||||
|
|
||||||
const cfgpath = os.dir(@FILE) + '/cfg'
|
const cfgpath = os.dir(@FILE) + '/cfg'
|
||||||
|
|
||||||
@@ -341,4 +343,3 @@ docusaurus.new(heroscript_path:cfgpath)!
|
|||||||
```
|
```
|
||||||
|
|
||||||
by just called do.vsh we can execute on the ebook
|
by just called do.vsh we can execute on the ebook
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ The `list` method accepts a `ListArgs` struct to control its behavior:
|
|||||||
```v
|
```v
|
||||||
pub struct ListArgs {
|
pub struct ListArgs {
|
||||||
pub mut:
|
pub mut:
|
||||||
regex []string // A slice of regular expressions to filter files.
|
regex []string // A slice of regular expressions to filter files.
|
||||||
recursive bool = true // Whether to list files recursively (default true).
|
recursive bool = true // Whether to list files recursively (default true).
|
||||||
ignore_default bool = true // Whether to ignore files starting with . and _ (default true).
|
ignore_default bool = true // Whether to ignore files starting with . and _ (default true).
|
||||||
include_links bool // Whether to include symbolic links in the list.
|
include_links bool // Whether to include symbolic links in the list.
|
||||||
dirs_only bool // Whether to include only directories in the list.
|
dirs_only bool // Whether to include only directories in the list.
|
||||||
files_only bool // Whether to include only files in the list.
|
files_only bool // Whether to include only files in the list.
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ Here are examples demonstrating how to use these advanced filtering options:
|
|||||||
You can use regular expressions to filter files based on their names or extensions. The `regex` parameter accepts a slice of strings, where each string is a regex pattern.
|
You can use regular expressions to filter files based on their names or extensions. The `regex` parameter accepts a slice of strings, where each string is a regex pattern.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
|
|
||||||
// Get a directory path
|
// Get a directory path
|
||||||
mut dir := pathlib.get('/some/directory')!
|
mut dir := pathlib.get('/some/directory')!
|
||||||
@@ -61,7 +61,7 @@ for path_obj in vlang_files.paths {
|
|||||||
By default, `list()` is recursive. You can disable recursion to list only items in the current directory.
|
By default, `list()` is recursive. You can disable recursion to list only items in the current directory.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
|
|
||||||
mut dir := pathlib.get('/some/directory')!
|
mut dir := pathlib.get('/some/directory')!
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ for path_obj in top_level_items.paths {
|
|||||||
The `ignore_default` parameter controls whether files and directories starting with `.` or `_` are ignored.
|
The `ignore_default` parameter controls whether files and directories starting with `.` or `_` are ignored.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
|
|
||||||
mut dir := pathlib.get('/some/directory')!
|
mut dir := pathlib.get('/some/directory')!
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ for path_obj in all_items.paths {
|
|||||||
By default, symbolic links are ignored when walking the directory structure. Set `include_links` to `true` to include them.
|
By default, symbolic links are ignored when walking the directory structure. Set `include_links` to `true` to include them.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
|
|
||||||
mut dir := pathlib.get('/some/directory')!
|
mut dir := pathlib.get('/some/directory')!
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ for path_obj in items_with_links.paths {
|
|||||||
Use `dirs_only` or `files_only` to restrict the results to only directories or only files.
|
Use `dirs_only` or `files_only` to restrict the results to only directories or only files.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
|
|
||||||
mut dir := pathlib.get('/some/directory')!
|
mut dir := pathlib.get('/some/directory')!
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ The `builder` module in Herolib provides a powerful framework for automating sys
|
|||||||
|
|
||||||
## Key Components
|
## Key Components
|
||||||
|
|
||||||
- **`BuilderFactory`**: Responsible for creating and managing `Node` instances.
|
- **`BuilderFactory`**: Responsible for creating and managing `Node` instances.
|
||||||
- **`Node`**: Represents a target system (local or remote). It encapsulates system properties (platform, CPU type, environment variables) and provides methods for interaction.
|
- **`Node`**: Represents a target system (local or remote). It encapsulates system properties (platform, CPU type, environment variables) and provides methods for interaction.
|
||||||
- **`Executor`**: An interface (implemented by `ExecutorLocal` and `ExecutorSSH`) that handles the actual command execution and file operations on the target system.
|
- **`Executor`**: An interface (implemented by `ExecutorLocal` and `ExecutorSSH`) that handles the actual command execution and file operations on the target system.
|
||||||
- **NodeDB (via `Node.done` map)**: A key-value store within each `Node` for persistent state, caching, and tracking execution history.
|
- **NodeDB (via `Node.done` map)**: A key-value store within each `Node` for persistent state, caching, and tracking execution history.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ The `builder` module in Herolib provides a powerful framework for automating sys
|
|||||||
First, import the `builder` module and create a new `BuilderFactory` instance. Then, create a `Node` object, which can represent either the local machine or a remote server.
|
First, import the `builder` module and create a new `BuilderFactory` instance. Then, create a `Node` object, which can represent either the local machine or a remote server.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder
|
import incubaid.herolib.builder
|
||||||
|
|
||||||
// Create a new builder factory
|
// Create a new builder factory
|
||||||
mut b := builder.new()!
|
mut b := builder.new()!
|
||||||
@@ -68,7 +68,7 @@ The `Node` object provides methods to execute commands on the target system.
|
|||||||
Executes a command and returns its standard output.
|
Executes a command and returns its standard output.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder { ExecArgs }
|
import incubaid.herolib.builder { ExecArgs }
|
||||||
|
|
||||||
// Execute a command with stdout
|
// Execute a command with stdout
|
||||||
result := node.exec(cmd: "ls -la /tmp", stdout: true)!
|
result := node.exec(cmd: "ls -la /tmp", stdout: true)!
|
||||||
@@ -101,7 +101,7 @@ node.exec_interactive("bash")!
|
|||||||
A more advanced command execution method that supports caching, periodic execution, and temporary script handling.
|
A more advanced command execution method that supports caching, periodic execution, and temporary script handling.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder { NodeExecCmd }
|
import incubaid.herolib.builder { NodeExecCmd }
|
||||||
|
|
||||||
// Execute a command, cache its result for 24 hours (48*3600 seconds)
|
// Execute a command, cache its result for 24 hours (48*3600 seconds)
|
||||||
// and provide a description for logging.
|
// and provide a description for logging.
|
||||||
@@ -130,7 +130,7 @@ println(script_output)
|
|||||||
Executes a command with retries until it succeeds or a timeout is reached.
|
Executes a command with retries until it succeeds or a timeout is reached.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder { ExecRetryArgs }
|
import incubaid.herolib.builder { ExecRetryArgs }
|
||||||
|
|
||||||
// Try to connect to a service, retrying every 100ms for up to 10 seconds
|
// Try to connect to a service, retrying every 100ms for up to 10 seconds
|
||||||
result := node.exec_retry(
|
result := node.exec_retry(
|
||||||
@@ -219,7 +219,7 @@ if node.dir_exists("/var/log") {
|
|||||||
Transfer files between the local machine and the target node using `rsync` or `scp`.
|
Transfer files between the local machine and the target node using `rsync` or `scp`.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder { SyncArgs }
|
import incubaid.herolib.builder { SyncArgs }
|
||||||
|
|
||||||
// Upload a local file to the remote node
|
// Upload a local file to the remote node
|
||||||
node.upload(
|
node.upload(
|
||||||
@@ -286,7 +286,7 @@ node.hero_install()!
|
|||||||
Updates the Herolib code on the node, with options for syncing from local, git reset, or git pull.
|
Updates the Herolib code on the node, with options for syncing from local, git reset, or git pull.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder { HeroUpdateArgs }
|
import incubaid.herolib.builder { HeroUpdateArgs }
|
||||||
|
|
||||||
// Sync local Herolib code to the remote node (full sync)
|
// Sync local Herolib code to the remote node (full sync)
|
||||||
node.hero_update(sync_from_local: true, sync_full: true)!
|
node.hero_update(sync_from_local: true, sync_full: true)!
|
||||||
@@ -300,7 +300,7 @@ node.hero_update(git_reset: true, branch: "dev")!
|
|||||||
Uploads and executes a Vlang script (`.vsh` or `.v`) on the remote node.
|
Uploads and executes a Vlang script (`.vsh` or `.v`) on the remote node.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder { VScriptArgs }
|
import incubaid.herolib.builder { VScriptArgs }
|
||||||
|
|
||||||
// Upload and execute a local V script on the remote node
|
// Upload and execute a local V script on the remote node
|
||||||
node.vscript(path: "/local/path/to/my_script.vsh", sync_from_local: true)!
|
node.vscript(path: "/local/path/to/my_script.vsh", sync_from_local: true)!
|
||||||
@@ -311,7 +311,7 @@ node.vscript(path: "/local/path/to/my_script.vsh", sync_from_local: true)!
|
|||||||
The `portforward_to_local` function allows forwarding a remote port on an SSH host to a local port.
|
The `portforward_to_local` function allows forwarding a remote port on an SSH host to a local port.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder { portforward_to_local, ForwardArgsToLocal }
|
import incubaid.herolib.builder { portforward_to_local, ForwardArgsToLocal }
|
||||||
|
|
||||||
// Forward remote port 8080 on 192.168.1.100 to local port 9000
|
// Forward remote port 8080 on 192.168.1.100 to local port 9000
|
||||||
portforward_to_local(
|
portforward_to_local(
|
||||||
|
|||||||
@@ -1,508 +1,682 @@
|
|||||||
# OSAL Core Module (freeflowuniverse.herolib.osal.core)
|
# OSAL Core Module (incubaid.herolib.osal.core)
|
||||||
|
|
||||||
This document describes the core functionalities of the Operating System Abstraction Layer (OSAL) module, designed for platform-independent system operations in V.
|
This document describes the core functionalities of the Operating System Abstraction Layer (OSAL) module, designed for platform-independent system operations in V.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
//example how to get started
|
//example how to get started
|
||||||
|
|
||||||
import freeflowuniverse.herolib.osal.core as osal
|
import incubaid.herolib.osal.core as osal
|
||||||
|
|
||||||
osal.exec(...)!
|
osal.exec(...)!
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 1. Process Management
|
## 1. Process Management
|
||||||
|
|
||||||
### `osal.exec(cmd: Command) !Job`
|
### `osal.exec(cmd: Command) !Job`
|
||||||
|
|
||||||
Executes a shell command with extensive configuration.
|
Executes a shell command with extensive configuration.
|
||||||
* **Parameters**:
|
|
||||||
* `cmd` (`Command` struct):
|
* **Parameters**:
|
||||||
* `cmd` (string): The command string.
|
* `cmd` (`Command` struct):
|
||||||
* `timeout` (int, default: 3600): Max execution time in seconds.
|
* `cmd` (string): The command string.
|
||||||
* `retry` (int): Number of retries on failure.
|
* `timeout` (int, default: 3600): Max execution time in seconds.
|
||||||
* `work_folder` (string): Working directory.
|
* `retry` (int): Number of retries on failure.
|
||||||
* `environment` (map[string]string): Environment variables.
|
* `work_folder` (string): Working directory.
|
||||||
* `stdout` (bool, default: true): Show command output.
|
* `environment` (map[string]string): Environment variables.
|
||||||
* `stdout_log` (bool, default: true): Log stdout to internal buffer.
|
* `stdout` (bool, default: true): Show command output.
|
||||||
* `raise_error` (bool, default: true): Raise V error on failure.
|
* `stdout_log` (bool, default: true): Log stdout to internal buffer.
|
||||||
* `ignore_error` (bool): Do not raise error, just report.
|
* `raise_error` (bool, default: true): Raise V error on failure.
|
||||||
* `debug` (bool): Enable debug output.
|
* `ignore_error` (bool): Do not raise error, just report.
|
||||||
* `shell` (bool): Execute in interactive shell.
|
* `debug` (bool): Enable debug output.
|
||||||
* `interactive` (bool, default: true): Run in interactive mode.
|
* `shell` (bool): Execute in interactive shell.
|
||||||
* `async` (bool): Run command asynchronously.
|
* `interactive` (bool, default: true): Run in interactive mode.
|
||||||
* `runtime` (`RunTime` enum): Specify runtime (`.bash`, `.python`, etc.).
|
* `async` (bool): Run command asynchronously.
|
||||||
* **Returns**: `Job` struct (contains `status`, `output`, `error`, `exit_code`, `start`, `end`, `process`, `runnr`).
|
* `runtime` (`RunTime` enum): Specify runtime (`.bash`, `.python`, etc.).
|
||||||
* **Error Handling**: Returns `JobError` with `error_type` (`.exec`, `.timeout`, `.args`).
|
* **Returns**: `Job` struct (contains `status`, `output`, `error`, `exit_code`, `start`, `end`, `process`, `runnr`).
|
||||||
|
* **Error Handling**: Returns `JobError` with `error_type` (`.exec`, `.timeout`, `.args`).
|
||||||
|
|
||||||
### `osal.execute_silent(cmd string) !string`
|
### `osal.execute_silent(cmd string) !string`
|
||||||
|
|
||||||
Executes a command silently.
|
Executes a command silently.
|
||||||
* **Parameters**: `cmd` (string): The command string.
|
|
||||||
* **Returns**: `string` (command output).
|
* **Parameters**: `cmd` (string): The command string.
|
||||||
|
* **Returns**: `string` (command output).
|
||||||
|
|
||||||
### `osal.execute_debug(cmd string) !string`
|
### `osal.execute_debug(cmd string) !string`
|
||||||
|
|
||||||
Executes a command with debug output.
|
Executes a command with debug output.
|
||||||
* **Parameters**: `cmd` (string): The command string.
|
|
||||||
* **Returns**: `string` (command output).
|
* **Parameters**: `cmd` (string): The command string.
|
||||||
|
* **Returns**: `string` (command output).
|
||||||
|
|
||||||
### `osal.execute_stdout(cmd string) !string`
|
### `osal.execute_stdout(cmd string) !string`
|
||||||
|
|
||||||
Executes a command and prints output to stdout.
|
Executes a command and prints output to stdout.
|
||||||
* **Parameters**: `cmd` (string): The command string.
|
|
||||||
* **Returns**: `string` (command output).
|
* **Parameters**: `cmd` (string): The command string.
|
||||||
|
* **Returns**: `string` (command output).
|
||||||
|
|
||||||
### `osal.execute_interactive(cmd string) !`
|
### `osal.execute_interactive(cmd string) !`
|
||||||
|
|
||||||
### `osal.execute_ok(cmd string) bool`
|
### `osal.execute_ok(cmd string) bool`
|
||||||
|
|
||||||
Executes a command and returns `true` if the command exits with a zero status, `false` otherwise.
|
Executes a command and returns `true` if the command exits with a zero status, `false` otherwise.
|
||||||
* **Parameters**: `cmd` (string): The command string.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `cmd` (string): The command string.
|
||||||
|
* **Returns**: `bool`.
|
||||||
Executes a command in an interactive shell.
|
Executes a command in an interactive shell.
|
||||||
|
|
||||||
### `osal.exec_fast(cmd: CommandFast) !string`
|
### `osal.exec_fast(cmd: CommandFast) !string`
|
||||||
|
|
||||||
Executes a command quickly, with options for profile sourcing and environment variables.
|
Executes a command quickly, with options for profile sourcing and environment variables.
|
||||||
* **Parameters**:
|
|
||||||
* `cmd` (`CommandFast` struct):
|
* **Parameters**:
|
||||||
* `cmd` (string): The command string.
|
* `cmd` (`CommandFast` struct):
|
||||||
* `ignore_error` (bool): Do not raise error on non-zero exit code.
|
* `cmd` (string): The command string.
|
||||||
* `work_folder` (string): Working directory.
|
* `ignore_error` (bool): Do not raise error on non-zero exit code.
|
||||||
* `environment` (map[string]string): Environment variables.
|
* `work_folder` (string): Working directory.
|
||||||
* `ignore_error_codes` ([]int): List of exit codes to ignore.
|
* `environment` (map[string]string): Environment variables.
|
||||||
* `debug` (bool): Enable debug output.
|
* `ignore_error_codes` ([]int): List of exit codes to ignore.
|
||||||
* `includeprofile` (bool): Source the user's profile before execution.
|
* `debug` (bool): Enable debug output.
|
||||||
* `notempty` (bool): Return an error if the output is empty.
|
* `includeprofile` (bool): Source the user's profile before execution.
|
||||||
* **Returns**: `string` (command output).
|
* `notempty` (bool): Return an error if the output is empty.
|
||||||
* **Parameters**: `cmd` (string): The command string.
|
* **Returns**: `string` (command output).
|
||||||
|
* **Parameters**: `cmd` (string): The command string.
|
||||||
|
|
||||||
### `osal.cmd_exists(cmd string) bool`
|
### `osal.cmd_exists(cmd string) bool`
|
||||||
|
|
||||||
Checks if a command exists in the system's PATH.
|
Checks if a command exists in the system's PATH.
|
||||||
* **Parameters**: `cmd` (string): The command name.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `cmd` (string): The command name.
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.processmap_get() !ProcessMap`
|
### `osal.processmap_get() !ProcessMap`
|
||||||
|
|
||||||
Scans and returns a map of all running processes.
|
Scans and returns a map of all running processes.
|
||||||
* **Returns**: `ProcessMap` struct (contains `processes` (`[]ProcessInfo`), `lastscan`, `state`, `pids`).
|
|
||||||
|
* **Returns**: `ProcessMap` struct (contains `processes` (`[]ProcessInfo`), `lastscan`, `state`, `pids`).
|
||||||
|
|
||||||
### `osal.processinfo_get(pid int) !ProcessInfo`
|
### `osal.processinfo_get(pid int) !ProcessInfo`
|
||||||
|
|
||||||
Retrieves detailed information for a specific process by PID.
|
Retrieves detailed information for a specific process by PID.
|
||||||
* **Parameters**: `pid` (int): Process ID.
|
|
||||||
* **Returns**: `ProcessInfo` struct (contains `cpu_perc`, `mem_perc`, `cmd`, `pid`, `ppid`, `rss`).
|
* **Parameters**: `pid` (int): Process ID.
|
||||||
|
* **Returns**: `ProcessInfo` struct (contains `cpu_perc`, `mem_perc`, `cmd`, `pid`, `ppid`, `rss`).
|
||||||
|
|
||||||
### `osal.processinfo_get_byname(name string) ![]ProcessInfo`
|
### `osal.processinfo_get_byname(name string) ![]ProcessInfo`
|
||||||
|
|
||||||
Retrieves detailed information for processes matching a given name.
|
Retrieves detailed information for processes matching a given name.
|
||||||
* **Parameters**: `name` (string): Process name (substring match).
|
|
||||||
* **Returns**: `[]ProcessInfo`.
|
* **Parameters**: `name` (string): Process name (substring match).
|
||||||
|
* **Returns**: `[]ProcessInfo`.
|
||||||
|
|
||||||
### `osal.process_exists(pid int) bool`
|
### `osal.process_exists(pid int) bool`
|
||||||
|
|
||||||
Checks if a process with a given PID exists.
|
Checks if a process with a given PID exists.
|
||||||
* **Parameters**: `pid` (int): Process ID.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `pid` (int): Process ID.
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.processinfo_with_children(pid int) !ProcessMap`
|
### `osal.processinfo_with_children(pid int) !ProcessMap`
|
||||||
|
|
||||||
Returns a process and all its child processes.
|
Returns a process and all its child processes.
|
||||||
|
|
||||||
## 1.1. Done Context Management (`done.v`)
|
## 1.1. Done Context Management (`done.v`)
|
||||||
|
|
||||||
Functions for managing a "done" context or state using Redis.
|
Functions for managing a "done" context or state using Redis.
|
||||||
|
|
||||||
* **`osal.done_set(key string, val string) !`**: Sets a key-value pair in the "done" context.
|
* **`osal.done_set(key string, val string) !`**: Sets a key-value pair in the "done" context.
|
||||||
* **`osal.done_get(key string) ?string`**: Retrieves a value from the "done" context by key.
|
* **`osal.done_get(key string) ?string`**: Retrieves a value from the "done" context by key.
|
||||||
* **`osal.done_delete(key string) !`**: Deletes a key from the "done" context.
|
* **`osal.done_delete(key string) !`**: Deletes a key from the "done" context.
|
||||||
* **`osal.done_get_str(key string) string`**: Retrieves a string value from the "done" context by key (panics on error).
|
* **`osal.done_get_str(key string) string`**: Retrieves a string value from the "done" context by key (panics on error).
|
||||||
* **`osal.done_get_int(key string) int`**: Retrieves an integer value from the "done" context by key (panics on error).
|
* **`osal.done_get_int(key string) int`**: Retrieves an integer value from the "done" context by key (panics on error).
|
||||||
* **`osal.done_exists(key string) bool`**: Checks if a key exists in the "done" context.
|
* **`osal.done_exists(key string) bool`**: Checks if a key exists in the "done" context.
|
||||||
* **`osal.done_print() !`**: Prints all key-value pairs in the "done" context to debug output.
|
* **`osal.done_print() !`**: Prints all key-value pairs in the "done" context to debug output.
|
||||||
* **`osal.done_reset() !`**: Resets (deletes all keys from) the "done" context.
|
* **`osal.done_reset() !`**: Resets (deletes all keys from) the "done" context.
|
||||||
* **Parameters**: `pid` (int): Parent Process ID.
|
* **Parameters**: `pid` (int): Parent Process ID.
|
||||||
* **Returns**: `ProcessMap`.
|
* **Returns**: `ProcessMap`.
|
||||||
|
|
||||||
### `osal.processinfo_children(pid int) !ProcessMap`
|
### `osal.processinfo_children(pid int) !ProcessMap`
|
||||||
|
|
||||||
Returns all child processes for a given PID.
|
Returns all child processes for a given PID.
|
||||||
* **Parameters**: `pid` (int): Parent Process ID.
|
|
||||||
* **Returns**: `ProcessMap`.
|
* **Parameters**: `pid` (int): Parent Process ID.
|
||||||
|
* **Returns**: `ProcessMap`.
|
||||||
|
|
||||||
### `osal.process_kill_recursive(args: ProcessKillArgs) !`
|
### `osal.process_kill_recursive(args: ProcessKillArgs) !`
|
||||||
|
|
||||||
Kills a process and all its children by name or PID.
|
Kills a process and all its children by name or PID.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`ProcessKillArgs` struct):
|
* **Parameters**:
|
||||||
* `name` (string): Process name.
|
* `args` (`ProcessKillArgs` struct):
|
||||||
* `pid` (int): Process ID.
|
* `name` (string): Process name.
|
||||||
|
* `pid` (int): Process ID.
|
||||||
|
|
||||||
### `osal.process_exists_byname(name string) !bool`
|
### `osal.process_exists_byname(name string) !bool`
|
||||||
|
|
||||||
Checks if a process with a given name exists.
|
Checks if a process with a given name exists.
|
||||||
* **Parameters**: `name` (string): Process name (substring match).
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `name` (string): Process name (substring match).
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.whoami() !string`
|
### `osal.whoami() !string`
|
||||||
|
|
||||||
Returns the current username.
|
Returns the current username.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
## 2. Network Utilities
|
## 2. Network Utilities
|
||||||
|
|
||||||
### `osal.ping(args: PingArgs) ! bool`
|
### `osal.ping(args: PingArgs) ! bool`
|
||||||
|
|
||||||
Checks host reachability.
|
Checks host reachability.
|
||||||
* **Parameters**:
|
|
||||||
|
* **Parameters**:
|
||||||
|
|
||||||
### `osal.ipaddr_pub_get_check() !string`
|
### `osal.ipaddr_pub_get_check() !string`
|
||||||
|
|
||||||
Retrieves the public IP address and verifies it is bound to a local interface.
|
Retrieves the public IP address and verifies it is bound to a local interface.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.is_ip_on_local_interface(ip string) !bool`
|
### `osal.is_ip_on_local_interface(ip string) !bool`
|
||||||
|
|
||||||
Checks if a given IP address is bound to a local network interface.
|
Checks if a given IP address is bound to a local network interface.
|
||||||
* **Parameters**: `ip` (string): IP address to check.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `ip` (string): IP address to check.
|
||||||
* `args` (`PingArgs` struct):
|
* **Returns**: `bool`.
|
||||||
* `address` (string, required): IP address or hostname.
|
* `args` (`PingArgs` struct):
|
||||||
* `count` (u8, default: 1): Number of pings.
|
* `address` (string, required): IP address or hostname.
|
||||||
* `timeout` (u16, default: 1): Timeout in seconds per ping.
|
* `count` (u8, default: 1): Number of pings.
|
||||||
* `retry` (u8): Number of retry attempts.
|
* `timeout` (u16, default: 1): Timeout in seconds per ping.
|
||||||
* **Returns**: `PingResult` enum (`.ok`, `.timeout`, `.unknownhost`).
|
* `retry` (u8): Number of retry attempts.
|
||||||
|
* **Returns**: `PingResult` enum (`.ok`, `.timeout`, `.unknownhost`).
|
||||||
|
|
||||||
### `osal.tcp_port_test(args: TcpPortTestArgs) bool`
|
### `osal.tcp_port_test(args: TcpPortTestArgs) bool`
|
||||||
|
|
||||||
Tests if a TCP port is open on a given address.
|
Tests if a TCP port is open on a given address.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`TcpPortTestArgs` struct):
|
* **Parameters**:
|
||||||
* `address` (string, required): IP address or hostname.
|
* `args` (`TcpPortTestArgs` struct):
|
||||||
* `port` (int, default: 22): TCP port number.
|
* `address` (string, required): IP address or hostname.
|
||||||
* `timeout` (u16, default: 2000): Total timeout in milliseconds.
|
* `port` (int, default: 22): TCP port number.
|
||||||
* **Returns**: `bool`.
|
* `timeout` (u16, default: 2000): Total timeout in milliseconds.
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.ipaddr_pub_get() !string`
|
### `osal.ipaddr_pub_get() !string`
|
||||||
|
|
||||||
Retrieves the public IP address.
|
Retrieves the public IP address.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.is_ip_on_local_interface(ip string) !bool`
|
### `osal.is_ip_on_local_interface(ip string) !bool`
|
||||||
|
|
||||||
Checks if a given IP address is bound to a local network interface.
|
Checks if a given IP address is bound to a local network interface.
|
||||||
* **Parameters**: `ip` (string): IP address to check.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `ip` (string): IP address to check.
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
## 3. File System Operations
|
## 3. File System Operations
|
||||||
|
|
||||||
### `osal.file_write(path string, text string) !`
|
### `osal.file_write(path string, text string) !`
|
||||||
|
|
||||||
Writes text content to a file.
|
Writes text content to a file.
|
||||||
* **Parameters**:
|
|
||||||
* `path` (string): File path.
|
* **Parameters**:
|
||||||
* `text` (string): Content to write.
|
* `path` (string): File path.
|
||||||
|
* `text` (string): Content to write.
|
||||||
|
|
||||||
### `osal.file_read(path string) !string`
|
### `osal.file_read(path string) !string`
|
||||||
|
|
||||||
Reads content from a file.
|
Reads content from a file.
|
||||||
* **Parameters**: `path` (string): File path.
|
|
||||||
* **Returns**: `string` (file content).
|
* **Parameters**: `path` (string): File path.
|
||||||
|
* **Returns**: `string` (file content).
|
||||||
|
|
||||||
### `osal.dir_ensure(path string) !`
|
### `osal.dir_ensure(path string) !`
|
||||||
|
|
||||||
Ensures a directory exists, creating it if necessary.
|
Ensures a directory exists, creating it if necessary.
|
||||||
* **Parameters**: `path` (string): Directory path.
|
|
||||||
|
* **Parameters**: `path` (string): Directory path.
|
||||||
|
|
||||||
### `osal.dir_delete(path string) !`
|
### `osal.dir_delete(path string) !`
|
||||||
|
|
||||||
Deletes a directory if it exists.
|
Deletes a directory if it exists.
|
||||||
* **Parameters**: `path` (string): Directory path.
|
|
||||||
|
* **Parameters**: `path` (string): Directory path.
|
||||||
|
|
||||||
### `osal.dir_reset(path string) !`
|
### `osal.dir_reset(path string) !`
|
||||||
|
|
||||||
Deletes and then recreates a directory.
|
Deletes and then recreates a directory.
|
||||||
* **Parameters**: `path` (string): Directory path.
|
|
||||||
|
* **Parameters**: `path` (string): Directory path.
|
||||||
|
|
||||||
### `osal.rm(todelete string) !`
|
### `osal.rm(todelete string) !`
|
||||||
|
|
||||||
Removes files or directories.
|
Removes files or directories.
|
||||||
* **Parameters**: `todelete` (string): Comma or newline separated list of paths (supports `~` for home directory).
|
|
||||||
|
* **Parameters**: `todelete` (string): Comma or newline separated list of paths (supports `~` for home directory).
|
||||||
|
|
||||||
### `osal.env_get_all() map[string]string`
|
### `osal.env_get_all() map[string]string`
|
||||||
|
|
||||||
Returns all existing environment variables as a map.
|
Returns all existing environment variables as a map.
|
||||||
* **Returns**: `map[string]string`.
|
|
||||||
|
* **Returns**: `map[string]string`.
|
||||||
|
|
||||||
## 4. Environment Variables
|
## 4. Environment Variables
|
||||||
|
|
||||||
## 4.1. Package Management (`package.v`)
|
## 4.1. Package Management (`package.v`)
|
||||||
|
|
||||||
Functions for managing system packages.
|
Functions for managing system packages.
|
||||||
|
|
||||||
* **`osal.package_refresh() !`**: Updates the package list for the detected platform.
|
* **`osal.package_refresh() !`**: Updates the package list for the detected platform.
|
||||||
* **`osal.package_install(name_ string) !`**: Installs one or more packages.
|
* **`osal.package_install(name_ string) !`**: Installs one or more packages.
|
||||||
* **`osal.package_remove(name_ string) !`**: Removes one or more packages.
|
* **`osal.package_remove(name_ string) !`**: Removes one or more packages.
|
||||||
|
|
||||||
### `osal.env_set(args: EnvSet)`
|
### `osal.env_set(args: EnvSet)`
|
||||||
|
|
||||||
Sets an environment variable.
|
Sets an environment variable.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`EnvSet` struct):
|
* **Parameters**:
|
||||||
* `key` (string, required): Environment variable name.
|
* `args` (`EnvSet` struct):
|
||||||
* `value` (string, required): Value to set.
|
* `key` (string, required): Environment variable name.
|
||||||
* `overwrite` (bool, default: true): Overwrite if exists.
|
* `value` (string, required): Value to set.
|
||||||
|
* `overwrite` (bool, default: true): Overwrite if exists.
|
||||||
|
|
||||||
### `osal.env_unset(key string)`
|
### `osal.env_unset(key string)`
|
||||||
|
|
||||||
Unsets a specific environment variable.
|
Unsets a specific environment variable.
|
||||||
* **Parameters**: `key` (string): Environment variable name.
|
|
||||||
|
* **Parameters**: `key` (string): Environment variable name.
|
||||||
|
|
||||||
### `osal.env_unset_all()`
|
### `osal.env_unset_all()`
|
||||||
|
|
||||||
Unsets all environment variables.
|
Unsets all environment variables.
|
||||||
|
|
||||||
### `osal.env_set_all(args: EnvSetAll)`
|
### `osal.env_set_all(args: EnvSetAll)`
|
||||||
|
|
||||||
Sets multiple environment variables.
|
Sets multiple environment variables.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`EnvSetAll` struct):
|
* **Parameters**:
|
||||||
* `env` (map[string]string): Map of key-value pairs.
|
* `args` (`EnvSetAll` struct):
|
||||||
* `clear_before_set` (bool): Clear all existing variables before setting.
|
* `env` (map[string]string): Map of key-value pairs.
|
||||||
* `overwrite_if_exists` (bool, default: true): Overwrite existing variables.
|
* `clear_before_set` (bool): Clear all existing variables before setting.
|
||||||
|
* `overwrite_if_exists` (bool, default: true): Overwrite existing variables.
|
||||||
|
|
||||||
### `osal.env_get(key string) !string`
|
### `osal.env_get(key string) !string`
|
||||||
|
|
||||||
Retrieves the value of a specific environment variable.
|
Retrieves the value of a specific environment variable.
|
||||||
* **Parameters**: `key` (string): Environment variable name.
|
|
||||||
* **Returns**: `string` (variable value).
|
* **Parameters**: `key` (string): Environment variable name.
|
||||||
|
* **Returns**: `string` (variable value).
|
||||||
|
|
||||||
### `osal.env_exists(key string) !bool`
|
### `osal.env_exists(key string) !bool`
|
||||||
|
|
||||||
Checks if an environment variable exists.
|
Checks if an environment variable exists.
|
||||||
* **Parameters**: `key` (string): Environment variable name.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `key` (string): Environment variable name.
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.env_get_default(key string, def string) string`
|
### `osal.env_get_default(key string, def string) string`
|
||||||
|
|
||||||
Retrieves an environment variable or a default value if not found.
|
Retrieves an environment variable or a default value if not found.
|
||||||
* **Parameters**:
|
|
||||||
* `key` (string): Environment variable name.
|
* **Parameters**:
|
||||||
* `def` (string): Default value.
|
* `key` (string): Environment variable name.
|
||||||
* **Returns**: `string`.
|
* `def` (string): Default value.
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.load_env_file(file_path string) !`
|
### `osal.load_env_file(file_path string) !`
|
||||||
|
|
||||||
Loads environment variables from a specified file.
|
Loads environment variables from a specified file.
|
||||||
* **Parameters**: `file_path` (string): Path to the environment file.
|
|
||||||
|
* **Parameters**: `file_path` (string): Path to the environment file.
|
||||||
|
|
||||||
## 5. Command & Profile Management
|
## 5. Command & Profile Management
|
||||||
|
|
||||||
### `osal.cmd_add(args: CmdAddArgs) !`
|
### `osal.cmd_add(args: CmdAddArgs) !`
|
||||||
|
|
||||||
Adds (copies or symlinks) a binary to system paths and updates user profiles.
|
Adds (copies or symlinks) a binary to system paths and updates user profiles.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`CmdAddArgs` struct):
|
* **Parameters**:
|
||||||
* `cmdname` (string): Name of the command (optional, derived from source if empty).
|
* `args` (`CmdAddArgs` struct):
|
||||||
* `source` (string, required): Path to the binary.
|
* `cmdname` (string): Name of the command (optional, derived from source if empty).
|
||||||
* `symlink` (bool): Create a symlink instead of copying.
|
* `source` (string, required): Path to the binary.
|
||||||
* `reset` (bool, default: true): Delete existing command if found.
|
* `symlink` (bool): Create a symlink instead of copying.
|
||||||
|
* `reset` (bool, default: true): Delete existing command if found.
|
||||||
|
|
||||||
### `osal.profile_path_add_hero() !string`
|
### `osal.profile_path_add_hero() !string`
|
||||||
|
|
||||||
Ensures the `~/hero/bin` path is added to the user's profile.
|
Ensures the `~/hero/bin` path is added to the user's profile.
|
||||||
* **Returns**: `string` (the `~/hero/bin` path).
|
|
||||||
|
* **Returns**: `string` (the `~/hero/bin` path).
|
||||||
|
|
||||||
### `osal.bin_path() !string`
|
### `osal.bin_path() !string`
|
||||||
|
|
||||||
Returns the preferred binary installation path (`~/hero/bin`).
|
Returns the preferred binary installation path (`~/hero/bin`).
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.hero_path() !string`
|
### `osal.hero_path() !string`
|
||||||
|
|
||||||
Returns the `~/hero` directory path.
|
Returns the `~/hero` directory path.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.usr_local_path() !string`
|
### `osal.usr_local_path() !string`
|
||||||
|
|
||||||
Returns `/usr/local` for Linux or `~/hero` for macOS.
|
Returns `/usr/local` for Linux or `~/hero` for macOS.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.cmd_exists_profile(cmd string) bool`
|
### `osal.cmd_exists_profile(cmd string) bool`
|
||||||
|
|
||||||
Checks if a command exists in the system's PATH, considering the user's profile.
|
Checks if a command exists in the system's PATH, considering the user's profile.
|
||||||
* **Parameters**: `cmd` (string): The command name.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `cmd` (string): The command name.
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.profile_path_source() !string`
|
### `osal.profile_path_source() !string`
|
||||||
|
|
||||||
Returns a source statement for the preferred profile file (e.g., `. /home/user/.zprofile`).
|
Returns a source statement for the preferred profile file (e.g., `. /home/user/.zprofile`).
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.profile_path_source_and() !string`
|
### `osal.profile_path_source_and() !string`
|
||||||
|
|
||||||
Returns a source statement followed by `&&` for command chaining, or empty if profile doesn't exist.
|
Returns a source statement followed by `&&` for command chaining, or empty if profile doesn't exist.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.profile_path_add_remove(args: ProfilePathAddRemoveArgs) !`
|
### `osal.profile_path_add_remove(args: ProfilePathAddRemoveArgs) !`
|
||||||
|
|
||||||
Adds and/or removes paths from specified or preferred user profiles.
|
Adds and/or removes paths from specified or preferred user profiles.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`ProfilePathAddRemoveArgs` struct):
|
* **Parameters**:
|
||||||
* `paths_profile` (string): Comma/newline separated list of profile file paths (optional, uses preferred if empty).
|
* `args` (`ProfilePathAddRemoveArgs` struct):
|
||||||
* `paths2add` (string): Comma/newline separated list of paths to add.
|
* `paths_profile` (string): Comma/newline separated list of profile file paths (optional, uses preferred if empty).
|
||||||
* `paths2delete` (string): Comma/newline separated list of paths to delete.
|
* `paths2add` (string): Comma/newline separated list of paths to add.
|
||||||
* `allprofiles` (bool): Apply to all known profile files.
|
* `paths2delete` (string): Comma/newline separated list of paths to delete.
|
||||||
|
* `allprofiles` (bool): Apply to all known profile files.
|
||||||
|
|
||||||
### `osal.cmd_path(cmd string) !string`
|
### `osal.cmd_path(cmd string) !string`
|
||||||
|
|
||||||
Returns the full path of an executable command using `which`.
|
Returns the full path of an executable command using `which`.
|
||||||
* **Parameters**: `cmd` (string): Command name.
|
|
||||||
* **Returns**: `string` (full path).
|
* **Parameters**: `cmd` (string): Command name.
|
||||||
|
* **Returns**: `string` (full path).
|
||||||
|
|
||||||
### `osal.cmd_delete(cmd string) !`
|
### `osal.cmd_delete(cmd string) !`
|
||||||
|
|
||||||
Deletes commands from their found locations.
|
Deletes commands from their found locations.
|
||||||
* **Parameters**: `cmd` (string): Command name.
|
|
||||||
|
* **Parameters**: `cmd` (string): Command name.
|
||||||
|
|
||||||
### `osal.profile_paths_all() ![]string`
|
### `osal.profile_paths_all() ![]string`
|
||||||
|
|
||||||
Lists all possible profile file paths in the OS.
|
Lists all possible profile file paths in the OS.
|
||||||
* **Returns**: `[]string`.
|
|
||||||
|
* **Returns**: `[]string`.
|
||||||
|
|
||||||
### `osal.profile_paths_preferred() ![]string`
|
### `osal.profile_paths_preferred() ![]string`
|
||||||
|
|
||||||
## 5.1. SSH Key Management (`ssh_key.v`)
|
## 5.1. SSH Key Management (`ssh_key.v`)
|
||||||
|
|
||||||
Functions and structs for managing SSH keys.
|
Functions and structs for managing SSH keys.
|
||||||
|
|
||||||
### `struct SSHKey`
|
### `struct SSHKey`
|
||||||
|
|
||||||
Represents an SSH key pair.
|
Represents an SSH key pair.
|
||||||
* **Fields**: `name` (string), `directory` (string).
|
|
||||||
* **Methods**:
|
* **Fields**: `name` (string), `directory` (string).
|
||||||
* `public_key_path() !pathlib.Path`: Returns the path to the public key.
|
* **Methods**:
|
||||||
* `private_key_path() !pathlib.Path`: Returns the path to the private key.
|
* `public_key_path() !pathlib.Path`: Returns the path to the public key.
|
||||||
* `public_key() !string`: Returns the content of the public key.
|
* `private_key_path() !pathlib.Path`: Returns the path to the private key.
|
||||||
* `private_key() !string`: Returns the content of the private key.
|
* `public_key() !string`: Returns the content of the public key.
|
||||||
|
* `private_key() !string`: Returns the content of the private key.
|
||||||
|
|
||||||
### `struct SSHConfig`
|
### `struct SSHConfig`
|
||||||
|
|
||||||
Configuration for SSH key operations.
|
Configuration for SSH key operations.
|
||||||
* **Fields**: `directory` (string, default: `~/.ssh`).
|
|
||||||
|
* **Fields**: `directory` (string, default: `~/.ssh`).
|
||||||
|
|
||||||
### `osal.get_ssh_key(key_name string, config SSHConfig) ?SSHKey`
|
### `osal.get_ssh_key(key_name string, config SSHConfig) ?SSHKey`
|
||||||
|
|
||||||
Retrieves a specific SSH key by name.
|
Retrieves a specific SSH key by name.
|
||||||
* **Parameters**: `key_name` (string), `config` (`SSHConfig` struct).
|
|
||||||
* **Returns**: `?SSHKey` (optional SSHKey struct).
|
* **Parameters**: `key_name` (string), `config` (`SSHConfig` struct).
|
||||||
|
* **Returns**: `?SSHKey` (optional SSHKey struct).
|
||||||
|
|
||||||
### `osal.list_ssh_keys(config SSHConfig) ![]SSHKey`
|
### `osal.list_ssh_keys(config SSHConfig) ![]SSHKey`
|
||||||
|
|
||||||
Lists all SSH keys in the specified directory.
|
Lists all SSH keys in the specified directory.
|
||||||
* **Parameters**: `config` (`SSHConfig` struct).
|
|
||||||
* **Returns**: `[]SSHKey`.
|
* **Parameters**: `config` (`SSHConfig` struct).
|
||||||
|
* **Returns**: `[]SSHKey`.
|
||||||
|
|
||||||
### `osal.new_ssh_key(key_name string, config SSHConfig) !SSHKey`
|
### `osal.new_ssh_key(key_name string, config SSHConfig) !SSHKey`
|
||||||
|
|
||||||
Creates a new SSH key pair.
|
Creates a new SSH key pair.
|
||||||
* **Parameters**: `key_name` (string), `config` (`SSHConfig` struct).
|
|
||||||
* **Returns**: `SSHKey`.
|
* **Parameters**: `key_name` (string), `config` (`SSHConfig` struct).
|
||||||
|
* **Returns**: `SSHKey`.
|
||||||
Lists preferred profile file paths based on the operating system.
|
Lists preferred profile file paths based on the operating system.
|
||||||
* **Returns**: `[]string`.
|
* **Returns**: `[]string`.
|
||||||
|
|
||||||
### `osal.profile_path() !string`
|
### `osal.profile_path() !string`
|
||||||
|
|
||||||
Returns the most preferred profile file path.
|
Returns the most preferred profile file path.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
## 6. System Information & Utilities
|
## 6. System Information & Utilities
|
||||||
|
|
||||||
### `osal.platform() !PlatformType`
|
### `osal.platform() !PlatformType`
|
||||||
|
|
||||||
Identifies the operating system.
|
Identifies the operating system.
|
||||||
* **Returns**: `PlatformType` enum (`.unknown`, `.osx`, `.ubuntu`, `.alpine`, `.arch`, `.suse`).
|
|
||||||
|
* **Returns**: `PlatformType` enum (`.unknown`, `.osx`, `.ubuntu`, `.alpine`, `.arch`, `.suse`).
|
||||||
|
|
||||||
### `osal.cputype() !CPUType`
|
### `osal.cputype() !CPUType`
|
||||||
|
|
||||||
Identifies the CPU architecture.
|
Identifies the CPU architecture.
|
||||||
* **Returns**: `CPUType` enum (`.unknown`, `.intel`, `.arm`, `.intel32`, `.arm32`).
|
|
||||||
|
* **Returns**: `CPUType` enum (`.unknown`, `.intel`, `.arm`, `.intel32`, `.arm32`).
|
||||||
|
|
||||||
### `osal.is_linux() !bool`
|
### `osal.is_linux() !bool`
|
||||||
|
|
||||||
Checks if the current OS is Linux.
|
Checks if the current OS is Linux.
|
||||||
* **Returns**: `bool`.
|
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.is_osx() !bool`
|
### `osal.is_osx() !bool`
|
||||||
|
|
||||||
Checks if the current OS is macOS.
|
Checks if the current OS is macOS.
|
||||||
* **Returns**: `bool`.
|
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.is_ubuntu() !bool`
|
### `osal.is_ubuntu() !bool`
|
||||||
|
|
||||||
Checks if the current OS is Ubuntu.
|
Checks if the current OS is Ubuntu.
|
||||||
* **Returns**: `bool`.
|
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.is_osx_arm() !bool`
|
### `osal.is_osx_arm() !bool`
|
||||||
|
|
||||||
Checks if the current OS is macOS ARM.
|
Checks if the current OS is macOS ARM.
|
||||||
* **Returns**: `bool`.
|
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.is_linux_arm() !bool`
|
### `osal.is_linux_arm() !bool`
|
||||||
|
|
||||||
Checks if the current OS is Linux ARM.
|
Checks if the current OS is Linux ARM.
|
||||||
* **Returns**: `bool`.
|
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.is_osx_intel() !bool`
|
### `osal.is_osx_intel() !bool`
|
||||||
|
|
||||||
Checks if the current OS is macOS Intel.
|
Checks if the current OS is macOS Intel.
|
||||||
* **Returns**: `bool`.
|
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.is_linux_intel() !bool`
|
### `osal.is_linux_intel() !bool`
|
||||||
|
|
||||||
Checks if the current OS is Linux Intel.
|
Checks if the current OS is Linux Intel.
|
||||||
* **Returns**: `bool`.
|
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.hostname() !string`
|
### `osal.hostname() !string`
|
||||||
|
|
||||||
Returns the system hostname.
|
Returns the system hostname.
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.initname() !string`
|
### `osal.initname() !string`
|
||||||
|
|
||||||
Returns the init system name (e.g., `systemd`, `bash`, `zinit`).
|
Returns the init system name (e.g., `systemd`, `bash`, `zinit`).
|
||||||
* **Returns**: `string`.
|
|
||||||
|
* **Returns**: `string`.
|
||||||
|
|
||||||
### `osal.sleep(duration int)`
|
### `osal.sleep(duration int)`
|
||||||
|
|
||||||
Pauses execution for a specified duration.
|
Pauses execution for a specified duration.
|
||||||
* **Parameters**: `duration` (int): Sleep duration in seconds.
|
|
||||||
|
* **Parameters**: `duration` (int): Sleep duration in seconds.
|
||||||
|
|
||||||
### `osal.download(args: DownloadArgs) !pathlib.Path`
|
### `osal.download(args: DownloadArgs) !pathlib.Path`
|
||||||
|
|
||||||
Downloads a file from a URL.
|
Downloads a file from a URL.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`DownloadArgs` struct):
|
* **Parameters**:
|
||||||
* `url` (string, required): URL of the file.
|
* `args` (`DownloadArgs` struct):
|
||||||
* `name` (string): Optional, derived from filename if empty.
|
* `url` (string, required): URL of the file.
|
||||||
* `reset` (bool): Force download, remove existing.
|
* `name` (string): Optional, derived from filename if empty.
|
||||||
* `hash` (string): Hash for verification.
|
* `reset` (bool): Force download, remove existing.
|
||||||
* `dest` (string): Destination path.
|
* `hash` (string): Hash for verification.
|
||||||
* `timeout` (int, default: 180): Download timeout in seconds.
|
* `dest` (string): Destination path.
|
||||||
* `retry` (int, default: 3): Number of retries.
|
* `timeout` (int, default: 180): Download timeout in seconds.
|
||||||
* `minsize_kb` (u32, default: 10): Minimum expected size in KB.
|
* `retry` (int, default: 3): Number of retries.
|
||||||
* `maxsize_kb` (u32): Maximum expected size in KB.
|
* `minsize_kb` (u32, default: 10): Minimum expected size in KB.
|
||||||
* `expand_dir` (string): Directory to expand archive into.
|
* `maxsize_kb` (u32): Maximum expected size in KB.
|
||||||
* `expand_file` (string): File to expand archive into.
|
* `expand_dir` (string): Directory to expand archive into.
|
||||||
* **Returns**: `pathlib.Path` (path to the downloaded file/directory).
|
* `expand_file` (string): File to expand archive into.
|
||||||
|
* **Returns**: `pathlib.Path` (path to the downloaded file/directory).
|
||||||
|
|
||||||
### `osal.user_exists(username string) bool`
|
### `osal.user_exists(username string) bool`
|
||||||
|
|
||||||
Checks if a user exists on the system.
|
Checks if a user exists on the system.
|
||||||
* **Parameters**: `username` (string): Username to check.
|
|
||||||
* **Returns**: `bool`.
|
* **Parameters**: `username` (string): Username to check.
|
||||||
|
* **Returns**: `bool`.
|
||||||
|
|
||||||
### `osal.user_id_get(username string) !int`
|
### `osal.user_id_get(username string) !int`
|
||||||
|
|
||||||
Retrieves the user ID for a given username.
|
Retrieves the user ID for a given username.
|
||||||
* **Parameters**: `username` (string): Username.
|
|
||||||
* **Returns**: `int` (User ID).
|
* **Parameters**: `username` (string): Username.
|
||||||
|
* **Returns**: `int` (User ID).
|
||||||
|
|
||||||
### `osal.user_add(args: UserArgs) !int`
|
### `osal.user_add(args: UserArgs) !int`
|
||||||
|
|
||||||
Adds a new user to the system.
|
Adds a new user to the system.
|
||||||
* **Parameters**:
|
|
||||||
* `args` (`UserArgs` struct):
|
* **Parameters**:
|
||||||
* `name` (string, required): Username to add.
|
* `args` (`UserArgs` struct):
|
||||||
* **Returns**: `int` (User ID of the added user).
|
* `name` (string, required): Username to add.
|
||||||
|
* **Returns**: `int` (User ID of the added user).
|
||||||
|
|
||||||
## Enums & Structs
|
## Enums & Structs
|
||||||
|
|
||||||
### `enum PlatformType`
|
### `enum PlatformType`
|
||||||
|
|
||||||
Represents the detected operating system.
|
Represents the detected operating system.
|
||||||
* Values: `unknown`, `osx`, `ubuntu`, `alpine`, `arch`, `suse`.
|
|
||||||
|
* Values: `unknown`, `osx`, `ubuntu`, `alpine`, `arch`, `suse`.
|
||||||
|
|
||||||
### `enum CPUType`
|
### `enum CPUType`
|
||||||
|
|
||||||
Represents the detected CPU architecture.
|
Represents the detected CPU architecture.
|
||||||
* Values: `unknown`, `intel`, `arm`, `intel32`, `arm32`.
|
|
||||||
|
* Values: `unknown`, `intel`, `arm`, `intel32`, `arm32`.
|
||||||
|
|
||||||
### `enum RunTime`
|
### `enum RunTime`
|
||||||
|
|
||||||
Specifies the runtime environment for command execution.
|
Specifies the runtime environment for command execution.
|
||||||
* Values: `bash`, `python`, `heroscript`, `herocmd`, `v`.
|
|
||||||
|
* Values: `bash`, `python`, `heroscript`, `herocmd`, `v`.
|
||||||
|
|
||||||
### `enum JobStatus`
|
### `enum JobStatus`
|
||||||
|
|
||||||
Status of an executed command job.
|
Status of an executed command job.
|
||||||
* Values: `init`, `running`, `error_exec`, `error_timeout`, `error_args`, `done`.
|
|
||||||
|
* Values: `init`, `running`, `error_exec`, `error_timeout`, `error_args`, `done`.
|
||||||
|
|
||||||
### `enum ErrorType`
|
### `enum ErrorType`
|
||||||
|
|
||||||
Types of errors that can occur during job execution.
|
Types of errors that can occur during job execution.
|
||||||
* Values: `exec`, `timeout`, `args`.
|
|
||||||
|
* Values: `exec`, `timeout`, `args`.
|
||||||
|
|
||||||
### `enum PingResult`
|
### `enum PingResult`
|
||||||
|
|
||||||
Result of a ping operation.
|
Result of a ping operation.
|
||||||
* Values: `ok`, `timeout`, `unknownhost`.
|
|
||||||
|
* Values: `ok`, `timeout`, `unknownhost`.
|
||||||
|
|
||||||
### `struct Command`
|
### `struct Command`
|
||||||
|
|
||||||
Configuration for `osal.exec` function. (See `osal.exec` parameters for fields).
|
Configuration for `osal.exec` function. (See `osal.exec` parameters for fields).
|
||||||
|
|
||||||
### `struct Job`
|
### `struct Job`
|
||||||
|
|
||||||
Result object returned by `osal.exec`. (See `osal.exec` returns for fields).
|
Result object returned by `osal.exec`. (See `osal.exec` returns for fields).
|
||||||
|
|
||||||
### `struct JobError`
|
### `struct JobError`
|
||||||
|
|
||||||
Error details for failed jobs.
|
Error details for failed jobs.
|
||||||
|
|
||||||
### `struct PingArgs`
|
### `struct PingArgs`
|
||||||
|
|
||||||
Arguments for `osal.ping` function. (See `osal.ping` parameters for fields).
|
Arguments for `osal.ping` function. (See `osal.ping` parameters for fields).
|
||||||
|
|
||||||
### `struct TcpPortTestArgs`
|
### `struct TcpPortTestArgs`
|
||||||
|
|
||||||
Arguments for `osal.tcp_port_test` function. (See `osal.tcp_port_test` parameters for fields).
|
Arguments for `osal.tcp_port_test` function. (See `osal.tcp_port_test` parameters for fields).
|
||||||
|
|
||||||
### `struct EnvSet`
|
### `struct EnvSet`
|
||||||
|
|
||||||
Arguments for `osal.env_set` function. (See `osal.env_set` parameters for fields).
|
Arguments for `osal.env_set` function. (See `osal.env_set` parameters for fields).
|
||||||
|
|
||||||
### `struct EnvSetAll`
|
### `struct EnvSetAll`
|
||||||
|
|
||||||
Arguments for `osal.env_set_all` function. (See `osal.env_set_all` parameters for fields).
|
Arguments for `osal.env_set_all` function. (See `osal.env_set_all` parameters for fields).
|
||||||
|
|
||||||
### `struct CmdAddArgs`
|
### `struct CmdAddArgs`
|
||||||
|
|
||||||
Arguments for `osal.cmd_add` function. (See `osal.cmd_add` parameters for fields).
|
Arguments for `osal.cmd_add` function. (See `osal.cmd_add` parameters for fields).
|
||||||
|
|
||||||
### `struct ProfilePathAddRemoveArgs`
|
### `struct ProfilePathAddRemoveArgs`
|
||||||
|
|
||||||
Arguments for `osal.profile_path_add_remove` function. (See `osal.profile_path_add_remove` parameters for fields).
|
Arguments for `osal.profile_path_add_remove` function. (See `osal.profile_path_add_remove` parameters for fields).
|
||||||
|
|
||||||
### `struct ProcessMap`
|
### `struct ProcessMap`
|
||||||
|
|
||||||
Contains a list of `ProcessInfo` objects.
|
Contains a list of `ProcessInfo` objects.
|
||||||
|
|
||||||
### `struct ProcessInfo`
|
### `struct ProcessInfo`
|
||||||
|
|
||||||
Detailed information about a single process. (See `osal.processinfo_get` returns for fields).
|
Detailed information about a single process. (See `osal.processinfo_get` returns for fields).
|
||||||
|
|
||||||
### `struct ProcessKillArgs`
|
### `struct ProcessKillArgs`
|
||||||
|
|
||||||
Arguments for `osal.process_kill_recursive` function. (See `osal.process_kill_recursive` parameters for fields).
|
Arguments for `osal.process_kill_recursive` function. (See `osal.process_kill_recursive` parameters for fields).
|
||||||
|
|
||||||
### `struct DownloadArgs`
|
### `struct DownloadArgs`
|
||||||
|
|
||||||
Arguments for `osal.download` function. (See `osal.download` parameters for fields).
|
Arguments for `osal.download` function. (See `osal.download` parameters for fields).
|
||||||
|
|
||||||
### `struct UserArgs`
|
### `struct UserArgs`
|
||||||
|
|
||||||
Arguments for `osal.user_add` function. (See `osal.user_add` parameters for fields).
|
Arguments for `osal.user_add` function. (See `osal.user_add` parameters for fields).
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
The `OurTime` module in V provides flexible time handling, supporting relative and absolute time formats, Unix timestamps, and formatting utilities.
|
The `OurTime` module in V provides flexible time handling, supporting relative and absolute time formats, Unix timestamps, and formatting utilities.
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
- Create time objects from strings or current time
|
- Create time objects from strings or current time
|
||||||
- Relative time expressions (e.g., `+1h`, `-2d`)
|
- Relative time expressions (e.g., `+1h`, `-2d`)
|
||||||
- Absolute time formats (e.g., `YYYY-MM-DD HH:mm:ss`)
|
- Absolute time formats (e.g., `YYYY-MM-DD HH:mm:ss`)
|
||||||
@@ -12,7 +13,7 @@ The `OurTime` module in V provides flexible time handling, supporting relative a
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
|
|
||||||
// Current time
|
// Current time
|
||||||
mut t := ourtime.now()
|
mut t := ourtime.now()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Herolib Spreadsheet Module for AI Prompt Engineering
|
# Herolib Spreadsheet Module for AI Prompt Engineering
|
||||||
|
|
||||||
This document provides an overview and usage instructions for the `freeflowuniverse.herolib.biz.spreadsheet` module, which offers a powerful software representation of a spreadsheet. This module is designed for business modeling, data analysis, and can be leveraged in AI prompt engineering scenarios where structured data manipulation and visualization are required.
|
This document provides an overview and usage instructions for the `incubaid.herolib.biz.spreadsheet` module, which offers a powerful software representation of a spreadsheet. This module is designed for business modeling, data analysis, and can be leveraged in AI prompt engineering scenarios where structured data manipulation and visualization are required.
|
||||||
|
|
||||||
## 1. Core Concepts
|
## 1. Core Concepts
|
||||||
|
|
||||||
@@ -10,16 +10,17 @@ The spreadsheet module revolves around three main entities: `Sheet`, `Row`, and
|
|||||||
|
|
||||||
The `Sheet` is the primary container, representing the entire spreadsheet.
|
The `Sheet` is the primary container, representing the entire spreadsheet.
|
||||||
|
|
||||||
* **Properties:**
|
* **Properties:**
|
||||||
* `name` (string): A unique identifier for the sheet.
|
* `name` (string): A unique identifier for the sheet.
|
||||||
* `rows` (map[string]&Row): A collection of `Row` objects, indexed by their names.
|
* `rows` (map[string]&Row): A collection of `Row` objects, indexed by their names.
|
||||||
* `nrcol` (int): The number of columns in the sheet (e.g., 60 for 5 years of monthly data).
|
* `nrcol` (int): The number of columns in the sheet (e.g., 60 for 5 years of monthly data).
|
||||||
* `params` (SheetParams): Configuration parameters, e.g., `visualize_cur` (boolean to display currency symbols).
|
* `params` (SheetParams): Configuration parameters, e.g., `visualize_cur` (boolean to display currency symbols).
|
||||||
* `currency` (currency.Currency): The default currency for the sheet (e.g., USD), used for automatic conversions.
|
* `currency` (currency.Currency): The default currency for the sheet (e.g., USD), used for automatic conversions.
|
||||||
|
|
||||||
|
* **Creation:**
|
||||||
|
|
||||||
* **Creation:**
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.biz.spreadsheet
|
import incubaid.herolib.biz.spreadsheet
|
||||||
|
|
||||||
// Create a new sheet named 'my_financial_sheet' with 60 columns (e.g., 60 months)
|
// Create a new sheet named 'my_financial_sheet' with 60 columns (e.g., 60 months)
|
||||||
mut my_sheet := spreadsheet.sheet_new(
|
mut my_sheet := spreadsheet.sheet_new(
|
||||||
@@ -33,28 +34,29 @@ The `Sheet` is the primary container, representing the entire spreadsheet.
|
|||||||
mut existing_sheet := spreadsheet.sheet_get('my_financial_sheet')!
|
mut existing_sheet := spreadsheet.sheet_get('my_financial_sheet')!
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Key Operations:**
|
* **Key Operations:**
|
||||||
* `sheet.row_get(name string) !&Row`: Retrieves a row by its name.
|
* `sheet.row_get(name string) !&Row`: Retrieves a row by its name.
|
||||||
* `sheet.cell_get(row string, col int) !&Cell`: Retrieves a cell by row name and column index.
|
* `sheet.cell_get(row string, col int) !&Cell`: Retrieves a cell by row name and column index.
|
||||||
* `sheet.row_delete(name string)` / `sheet.delete(name string)`: Deletes a row.
|
* `sheet.row_delete(name string)` / `sheet.delete(name string)`: Deletes a row.
|
||||||
* `sheet.cells_width(colnr int) !int`: Finds the maximum string length of cells in a given column.
|
* `sheet.cells_width(colnr int) !int`: Finds the maximum string length of cells in a given column.
|
||||||
* `sheet.rows_names_width_max() int`: Returns the maximum width of row names/aliases.
|
* `sheet.rows_names_width_max() int`: Returns the maximum width of row names/aliases.
|
||||||
* `sheet.rows_description_width_max() int`: Returns the maximum width of row descriptions.
|
* `sheet.rows_description_width_max() int`: Returns the maximum width of row descriptions.
|
||||||
* `sheet.header() ![]string`: Generates column headers (e.g., "M1", "Q1", "Y1") based on `nrcol`.
|
* `sheet.header() ![]string`: Generates column headers (e.g., "M1", "Q1", "Y1") based on `nrcol`.
|
||||||
|
|
||||||
### 1.2. Row
|
### 1.2. Row
|
||||||
|
|
||||||
A `Row` represents a single horizontal line of data within a `Sheet`.
|
A `Row` represents a single horizontal line of data within a `Sheet`.
|
||||||
|
|
||||||
* **Properties:**
|
* **Properties:**
|
||||||
* `name` (string): Unique identifier for the row.
|
* `name` (string): Unique identifier for the row.
|
||||||
* `alias` (string, optional): Alternative name.
|
* `alias` (string, optional): Alternative name.
|
||||||
* `description` (string): Textual description.
|
* `description` (string): Textual description.
|
||||||
* `tags` (string): Space-separated tags for categorization (e.g., "department:hr location:belgium").
|
* `tags` (string): Space-separated tags for categorization (e.g., "department:hr location:belgium").
|
||||||
* `cells` ([]Cell): List of `Cell` objects.
|
* `cells` ([]Cell): List of `Cell` objects.
|
||||||
* `aggregatetype` (RowAggregateType): Defines default aggregation for this row (`.sum`, `.avg`, `.max`, `.min`).
|
* `aggregatetype` (RowAggregateType): Defines default aggregation for this row (`.sum`, `.avg`, `.max`, `.min`).
|
||||||
|
|
||||||
|
* **Creation (within a Sheet):**
|
||||||
|
|
||||||
* **Creation (within a Sheet):**
|
|
||||||
```v
|
```v
|
||||||
// Assuming 'my_sheet' is an existing Sheet object
|
// Assuming 'my_sheet' is an existing Sheet object
|
||||||
mut salaries_row := my_sheet.row_new(
|
mut salaries_row := my_sheet.row_new(
|
||||||
@@ -65,21 +67,21 @@ A `Row` represents a single horizontal line of data within a `Sheet`.
|
|||||||
)!
|
)!
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Key Operations:**
|
* **Key Operations:**
|
||||||
* `row.values_get() []f64`: Returns all cell values in the row as a list of floats.
|
* `row.values_get() []f64`: Returns all cell values in the row as a list of floats.
|
||||||
|
|
||||||
### 1.3. Cell
|
### 1.3. Cell
|
||||||
|
|
||||||
A `Cell` is the fundamental unit of data, storing a numeric value.
|
A `Cell` is the fundamental unit of data, storing a numeric value.
|
||||||
|
|
||||||
* **Properties:**
|
* **Properties:**
|
||||||
* `val` (f64): The numeric value.
|
* `val` (f64): The numeric value.
|
||||||
* `empty` (bool): `true` if the cell is empty.
|
* `empty` (bool): `true` if the cell is empty.
|
||||||
|
|
||||||
* **Key Operations:**
|
* **Key Operations:**
|
||||||
* `cell.set(v string) !`: Sets the cell's value. Handles currency strings (e.g., "100 USD") by converting to the sheet's currency.
|
* `cell.set(v string) !`: Sets the cell's value. Handles currency strings (e.g., "100 USD") by converting to the sheet's currency.
|
||||||
* `cell.add(v f64)`: Adds a numeric value to the existing cell value.
|
* `cell.add(v f64)`: Adds a numeric value to the existing cell value.
|
||||||
* `cell.repr() string`: Returns a formatted string representation of the value (e.g., "100.00", or "-" if empty).
|
* `cell.repr() string`: Returns a formatted string representation of the value (e.g., "100.00", or "-" if empty).
|
||||||
|
|
||||||
## 2. Data Aggregation and Transformation
|
## 2. Data Aggregation and Transformation
|
||||||
|
|
||||||
@@ -144,10 +146,10 @@ csv_string := my_sheet.export_csv(path: '')!
|
|||||||
println(csv_string)
|
println(csv_string)
|
||||||
```
|
```
|
||||||
|
|
||||||
* **`ExportCSVArgs` Parameters:**
|
* **`ExportCSVArgs` Parameters:**
|
||||||
* `path` (string, optional): File path. Empty string returns content as string. `~` is expanded to home directory.
|
* `path` (string, optional): File path. Empty string returns content as string. `~` is expanded to home directory.
|
||||||
* `include_empty` (bool, optional, default: `false`): If `true`, empty cells are included.
|
* `include_empty` (bool, optional, default: `false`): If `true`, empty cells are included.
|
||||||
* `separator` (string, optional, default: `'|'`): Delimiter character.
|
* `separator` (string, optional, default: `'|'`): Delimiter character.
|
||||||
|
|
||||||
## 4. Charting Capabilities
|
## 4. Charting Capabilities
|
||||||
|
|
||||||
@@ -157,25 +159,26 @@ Integrates with ECharts for data visualization. Charting functions return an `ec
|
|||||||
|
|
||||||
Used across line, bar, and pie charts to specify data and presentation.
|
Used across line, bar, and pie charts to specify data and presentation.
|
||||||
|
|
||||||
* `rowname` (string, optional): Single row name or comma-separated list.
|
* `rowname` (string, optional): Single row name or comma-separated list.
|
||||||
* `namefilter` ([]string, optional): List of exact row names to include.
|
* `namefilter` ([]string, optional): List of exact row names to include.
|
||||||
* `includefilter` ([]string, optional): List of tags to include.
|
* `includefilter` ([]string, optional): List of tags to include.
|
||||||
* `excludefilter` ([]string, optional): List of tags to exclude.
|
* `excludefilter` ([]string, optional): List of tags to exclude.
|
||||||
* `period_type` (PeriodType, optional): X-axis period (`.month`, `.quarter`, `.year`).
|
* `period_type` (PeriodType, optional): X-axis period (`.month`, `.quarter`, `.year`).
|
||||||
* `aggregate` (bool, optional, default: `true`): Aggregate multiple matching rows.
|
* `aggregate` (bool, optional, default: `true`): Aggregate multiple matching rows.
|
||||||
* `aggregatetype` (RowAggregateType, optional, default: `.sum`): Aggregation type.
|
* `aggregatetype` (RowAggregateType, optional, default: `.sum`): Aggregation type.
|
||||||
* `unit` (UnitType, optional): Data unit.
|
* `unit` (UnitType, optional): Data unit.
|
||||||
* `title`, `title_sub` (string, optional): Chart titles.
|
* `title`, `title_sub` (string, optional): Chart titles.
|
||||||
* `size` (string, optional): For pie charts, defines radius (e.g., "70%").
|
* `size` (string, optional): For pie charts, defines radius (e.g., "70%").
|
||||||
* `rowname_show` (bool, optional, default: `true`): Show row name in legend.
|
* `rowname_show` (bool, optional, default: `true`): Show row name in legend.
|
||||||
* `descr_show` (bool, optional, default: `false`): Show row description (overrides `rowname_show`).
|
* `descr_show` (bool, optional, default: `false`): Show row description (overrides `rowname_show`).
|
||||||
* `description` (string, optional): General chart description.
|
* `description` (string, optional): General chart description.
|
||||||
|
|
||||||
### 4.2. Chart Types
|
### 4.2. Chart Types
|
||||||
|
|
||||||
* **Line Chart (`line_chart`)**: Visualizes trends over time.
|
* **Line Chart (`line_chart`)**: Visualizes trends over time.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.web.echarts // Required for EChartsOption type
|
import incubaid.herolib.web.echarts // Required for EChartsOption type
|
||||||
|
|
||||||
line_chart_option := my_sheet.line_chart(
|
line_chart_option := my_sheet.line_chart(
|
||||||
rowname: 'revenue_row,expenses_row',
|
rowname: 'revenue_row,expenses_row',
|
||||||
@@ -184,7 +187,8 @@ Used across line, bar, and pie charts to specify data and presentation.
|
|||||||
)!
|
)!
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Bar Chart (`bar_chart`)**: Compares discrete categories or values.
|
* **Bar Chart (`bar_chart`)**: Compares discrete categories or values.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
bar_chart_option := my_sheet.bar_chart(
|
bar_chart_option := my_sheet.bar_chart(
|
||||||
rowname: 'profit_row',
|
rowname: 'profit_row',
|
||||||
@@ -193,7 +197,8 @@ Used across line, bar, and pie charts to specify data and presentation.
|
|||||||
)!
|
)!
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Pie Chart (`pie_chart`)**: Shows proportions of categories.
|
* **Pie Chart (`pie_chart`)**: Shows proportions of categories.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
pie_chart_option := my_sheet.pie_chart(
|
pie_chart_option := my_sheet.pie_chart(
|
||||||
rowname: 'budget_allocation_row',
|
rowname: 'budget_allocation_row',
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Chalk offers functions:- `console.color_fg(text string, color string)` - To chan
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
|
|
||||||
# basic usage
|
# basic usage
|
||||||
println('I am really ' + console.color_fg('happy', 'green'))
|
println('I am really ' + console.color_fg('happy', 'green'))
|
||||||
|
|||||||
@@ -6,39 +6,39 @@ the following is a good pragmatic way to remember clients, installers as a globa
|
|||||||
|
|
||||||
module docsite
|
module docsite
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.texttools
|
import incubaid.herolib.core.texttools
|
||||||
|
|
||||||
__global (
|
__global (
|
||||||
siteconfigs map[string]&SiteConfig
|
siteconfigs map[string]&SiteConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct FactoryArgs {
|
pub struct FactoryArgs {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string = "default"
|
name string = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(args FactoryArgs) !&SiteConfig {
|
pub fn new(args FactoryArgs) !&SiteConfig {
|
||||||
name := texttools.name_fix(args.name)
|
name := texttools.name_fix(args.name)
|
||||||
siteconfigs[name] = &SiteConfig{
|
siteconfigs[name] = &SiteConfig{
|
||||||
name: name
|
name: name
|
||||||
}
|
}
|
||||||
return get(name:name)!
|
return get(name:name)!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(args FactoryArgs) !&SiteConfig {
|
pub fn get(args FactoryArgs) !&SiteConfig {
|
||||||
name := texttools.name_fix(args.name)
|
name := texttools.name_fix(args.name)
|
||||||
mut sc := siteconfigs[name] or {
|
mut sc := siteconfigs[name] or {
|
||||||
return error('siteconfig with name "${name}" does not exist')
|
return error('siteconfig with name "${name}" does not exist')
|
||||||
}
|
}
|
||||||
return sc
|
return sc
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default() !&SiteConfig {
|
pub fn default() !&SiteConfig {
|
||||||
if siteconfigs.len == 0 {
|
if siteconfigs.len == 0 {
|
||||||
return new(name:'default')!
|
return new(name:'default')!
|
||||||
}
|
}
|
||||||
return get()!
|
return get()!
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -6,49 +6,49 @@ HeroScript is a concise scripting language with the following structure:
|
|||||||
|
|
||||||
```heroscript
|
```heroscript
|
||||||
!!actor.action_name
|
!!actor.action_name
|
||||||
param1: 'value1'
|
param1: 'value1'
|
||||||
param2: 'value with spaces'
|
param2: 'value with spaces'
|
||||||
multiline_description: '
|
multiline_description: '
|
||||||
This is a multiline description.
|
This is a multiline description.
|
||||||
It can span multiple lines.
|
It can span multiple lines.
|
||||||
'
|
'
|
||||||
arg1 arg2 // Arguments without keys
|
arg1 arg2 // Arguments without keys
|
||||||
```
|
```
|
||||||
|
|
||||||
Key characteristics:
|
Key characteristics:
|
||||||
- **Actions**: Start with `!!`, followed by `actor.action_name` (e.g., `!!mailclient.configure`).
|
|
||||||
- **Parameters**: Defined as `key:value`. Values can be quoted for spaces.
|
- **Actions**: Start with `!!`, followed by `actor.action_name` (e.g., `!!mailclient.configure`).
|
||||||
- **Multiline Support**: Parameters like `description` can span multiple lines.
|
- **Parameters**: Defined as `key:value`. Values can be quoted for spaces.
|
||||||
- **Arguments**: Values without keys (e.g., `arg1`).
|
- **Multiline Support**: Parameters like `description` can span multiple lines.
|
||||||
|
- **Arguments**: Values without keys (e.g., `arg1`).
|
||||||
|
|
||||||
## Processing HeroScript in Vlang
|
## Processing HeroScript in Vlang
|
||||||
|
|
||||||
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters, this is used in most of the herolib modules, it allows configuration or actions in a structured way.
|
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters, this is used in most of the herolib modules, it allows configuration or actions in a structured way.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
import incubaid.herolib.core.playbook { PlayBook }
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
|
|
||||||
pub fn play(mut plbook PlayBook) ! {
|
pub fn play(mut plbook PlayBook) ! {
|
||||||
|
|
||||||
if plbook.exists_once(filter: 'docusaurus.define') {
|
if plbook.exists_once(filter: 'docusaurus.define') {
|
||||||
mut action := plbook.get(filter: 'docusaurus.define')!
|
mut action := plbook.get(filter: 'docusaurus.define')!
|
||||||
mut p := action.params
|
mut p := action.params
|
||||||
//example how we get parameters from the action see core_params.md for more details
|
//example how we get parameters from the action see core_params.md for more details
|
||||||
ds = new(
|
ds = new(
|
||||||
path: p.get_default('path_publish', '')!
|
path: p.get_default('path_publish', '')!
|
||||||
production: p.get_default_false('production')
|
production: p.get_default_false('production')
|
||||||
)!
|
)!
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process 'docusaurus.add' actions to configure individual Docusaurus sites
|
// Process 'docusaurus.add' actions to configure individual Docusaurus sites
|
||||||
actions := plbook.find(filter: 'docusaurus.add')!
|
actions := plbook.find(filter: 'docusaurus.add')!
|
||||||
for action in actions {
|
for action in actions {
|
||||||
mut p := action.params
|
mut p := action.params
|
||||||
//do more processing here
|
//do more processing here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
For detailed information on parameter retrieval methods (e.g., `p.get()`, `p.get_int()`, `p.get_default_true()`), refer to `aiprompts/ai_core/core_params.md`.
|
For detailed information on parameter retrieval methods (e.g., `p.get()`, `p.get_int()`, `p.get_default_true()`), refer to `aiprompts/ai_core/core_params.md`.
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters.
|
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import freeflowuniverse.herolib.core.playcmds
|
import incubaid.herolib.core.playcmds
|
||||||
|
|
||||||
// path string
|
// path string
|
||||||
// text string
|
// text string
|
||||||
@@ -21,5 +21,3 @@ mut plbook := playbook.new(path: "....")!
|
|||||||
playcmds.run(mut plbook)!
|
playcmds.run(mut plbook)!
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
The `HTTPConnection` module provides a robust HTTP client for Vlang, supporting JSON, custom headers, retries, and caching.
|
The `HTTPConnection` module provides a robust HTTP client for Vlang, supporting JSON, custom headers, retries, and caching.
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
- Type-safe JSON methods
|
- Type-safe JSON methods
|
||||||
- Custom headers
|
- Custom headers
|
||||||
- Retry mechanism
|
- Retry mechanism
|
||||||
@@ -12,7 +13,7 @@ The `HTTPConnection` module provides a robust HTTP client for Vlang, supporting
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.httpconnection
|
import incubaid.herolib.core.httpconnection
|
||||||
|
|
||||||
// Create a new HTTP connection
|
// Create a new HTTP connection
|
||||||
mut conn := httpconnection.new(
|
mut conn := httpconnection.new(
|
||||||
@@ -30,17 +31,17 @@ To integrate `HTTPConnection` into a management class (e.g., `HetznerManager`),
|
|||||||
```v
|
```v
|
||||||
// Example: HetznerManager
|
// Example: HetznerManager
|
||||||
pub fn (mut h HetznerManager) connection() !&httpconnection.HTTPConnection {
|
pub fn (mut h HetznerManager) connection() !&httpconnection.HTTPConnection {
|
||||||
mut c := h.conn or {
|
mut c := h.conn or {
|
||||||
mut c2 := httpconnection.new(
|
mut c2 := httpconnection.new(
|
||||||
name: 'hetzner_${h.name}'
|
name: 'hetzner_${h.name}'
|
||||||
url: h.baseurl
|
url: h.baseurl
|
||||||
cache: true
|
cache: true
|
||||||
retry: 3
|
retry: 3
|
||||||
)!
|
)!
|
||||||
c2.basic_auth(h.user, h.password)
|
c2.basic_auth(h.user, h.password)
|
||||||
c2
|
c2
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# OSAL Core Module - Key Capabilities (freeflowuniverse.herolib.osal.core)
|
# OSAL Core Module - Key Capabilities (incubaid.herolib.osal.core)
|
||||||
|
|
||||||
```v
|
```v
|
||||||
//example how to get started
|
//example how to get started
|
||||||
|
|
||||||
import freeflowuniverse.herolib.osal.core as osal
|
import incubaid.herolib.osal.core as osal
|
||||||
|
|
||||||
job := osal.exec(cmd: 'ls /')!
|
job := osal.exec(cmd: 'ls /')!
|
||||||
```
|
```
|
||||||
@@ -12,70 +12,70 @@ This document describes the core functionalities of the Operating System Abstrac
|
|||||||
|
|
||||||
## 1. Process Execution
|
## 1. Process Execution
|
||||||
|
|
||||||
* **`osal.exec(cmd: Command) !Job`**: Execute a shell command.
|
* **`osal.exec(cmd: Command) !Job`**: Execute a shell command.
|
||||||
* **Key Parameters**: `cmd` (string), `timeout` (int), `retry` (int), `work_folder` (string), `environment` (map[string]string), `stdout` (bool), `raise_error` (bool).
|
* **Key Parameters**: `cmd` (string), `timeout` (int), `retry` (int), `work_folder` (string), `environment` (map[string]string), `stdout` (bool), `raise_error` (bool).
|
||||||
* **Returns**: `Job` (status, output, error, exit code).
|
* **Returns**: `Job` (status, output, error, exit code).
|
||||||
* **`osal.execute_silent(cmd string) !string`**: Execute silently, return output.
|
* **`osal.execute_silent(cmd string) !string`**: Execute silently, return output.
|
||||||
* **`osal.execute_debug(cmd string) !string`**: Execute with debug output, return output.
|
* **`osal.execute_debug(cmd string) !string`**: Execute with debug output, return output.
|
||||||
* **`osal.execute_stdout(cmd string) !string`**: Execute and print output to stdout, return output.
|
* **`osal.execute_stdout(cmd string) !string`**: Execute and print output to stdout, return output.
|
||||||
* **`osal.execute_interactive(cmd string) !`**: Execute in an interactive shell.
|
* **`osal.execute_interactive(cmd string) !`**: Execute in an interactive shell.
|
||||||
* **`osal.cmd_exists(cmd string) bool`**: Check if a command exists.
|
* **`osal.cmd_exists(cmd string) bool`**: Check if a command exists.
|
||||||
|
|
||||||
## 2. Network Utilities
|
## 2. Network Utilities
|
||||||
|
|
||||||
* **`osal.ping(args: PingArgs) !bool`**: Check host reachability.
|
* **`osal.ping(args: PingArgs) !bool`**: Check host reachability.
|
||||||
- address string = "8.8.8.8"
|
- address string = "8.8.8.8"
|
||||||
- nr_ping u16 = 3 // amount of ping requests we will do
|
- nr_ping u16 = 3 // amount of ping requests we will do
|
||||||
- nr_ok u16 = 3 //how many of them need to be ok
|
- nr_ok u16 = 3 //how many of them need to be ok
|
||||||
- retry u8 //how many times fo we retry above sequence, basically we ping ourselves with -c 1
|
- retry u8 //how many times fo we retry above sequence, basically we ping ourselves with -c 1
|
||||||
**`osal.ipaddr_pub_get() !string`**: Get public IP address.
|
**`osal.ipaddr_pub_get() !string`**: Get public IP address.
|
||||||
|
|
||||||
## 3. File System Operations
|
## 3. File System Operations
|
||||||
|
|
||||||
* **`osal.file_write(path string, text string) !`**: Write text to a file.
|
* **`osal.file_write(path string, text string) !`**: Write text to a file.
|
||||||
* **`osal.file_read(path string) !string`**: Read content from a file.
|
* **`osal.file_read(path string) !string`**: Read content from a file.
|
||||||
* **`osal.dir_ensure(path string) !`**: Ensure a directory exists.
|
* **`osal.dir_ensure(path string) !`**: Ensure a directory exists.
|
||||||
* **`osal.rm(todelete string) !`**: Remove files/directories.
|
* **`osal.rm(todelete string) !`**: Remove files/directories.
|
||||||
|
|
||||||
## 4. Environment Variables
|
## 4. Environment Variables
|
||||||
|
|
||||||
* **`osal.env_set(args: EnvSet)`**: Set an environment variable.
|
* **`osal.env_set(args: EnvSet)`**: Set an environment variable.
|
||||||
* **Key Parameters**: `key` (string), `value` (string).
|
* **Key Parameters**: `key` (string), `value` (string).
|
||||||
* **`osal.env_unset(key string)`**: Unset a specific environment variable.
|
* **`osal.env_unset(key string)`**: Unset a specific environment variable.
|
||||||
* **`osal.env_unset_all()`**: Unset all environment variables.
|
* **`osal.env_unset_all()`**: Unset all environment variables.
|
||||||
* **`osal.env_set_all(args: EnvSetAll)`**: Set multiple environment variables.
|
* **`osal.env_set_all(args: EnvSetAll)`**: Set multiple environment variables.
|
||||||
* **Key Parameters**: `env` (map[string]string), `clear_before_set` (bool), `overwrite_if_exists` (bool).
|
* **Key Parameters**: `env` (map[string]string), `clear_before_set` (bool), `overwrite_if_exists` (bool).
|
||||||
* **`osal.env_get(key string) !string`**: Get an environment variable's value.
|
* **`osal.env_get(key string) !string`**: Get an environment variable's value.
|
||||||
* **`osal.env_exists(key string) !bool`**: Check if an environment variable exists.
|
* **`osal.env_exists(key string) !bool`**: Check if an environment variable exists.
|
||||||
* **`osal.env_get_default(key string, def string) string`**: Get an environment variable or a default value.
|
* **`osal.env_get_default(key string, def string) string`**: Get an environment variable or a default value.
|
||||||
* **`osal.load_env_file(file_path string) !`**: Load variables from a file.
|
* **`osal.load_env_file(file_path string) !`**: Load variables from a file.
|
||||||
|
|
||||||
## 5. Command & Profile Management
|
## 5. Command & Profile Management
|
||||||
|
|
||||||
* **`osal.cmd_add(args: CmdAddArgs) !`**: Add a binary to system paths and update profiles.
|
* **`osal.cmd_add(args: CmdAddArgs) !`**: Add a binary to system paths and update profiles.
|
||||||
* **Key Parameters**: `source` (string, required), `cmdname` (string).
|
* **Key Parameters**: `source` (string, required), `cmdname` (string).
|
||||||
* **`osal.profile_path_add_remove(args: ProfilePathAddRemoveArgs) !`**: Add/remove paths from profiles.
|
* **`osal.profile_path_add_remove(args: ProfilePathAddRemoveArgs) !`**: Add/remove paths from profiles.
|
||||||
* **Key Parameters**: `paths2add` (string), `paths2delete` (string).
|
* **Key Parameters**: `paths2add` (string), `paths2delete` (string).
|
||||||
|
|
||||||
## 6. System Information & Utilities
|
## 6. System Information & Utilities
|
||||||
|
|
||||||
* **`osal.processmap_get() !ProcessMap`**: Get a map of all running processes.
|
* **`osal.processmap_get() !ProcessMap`**: Get a map of all running processes.
|
||||||
* **`osal.processinfo_get(pid int) !ProcessInfo`**: Get detailed information for a specific process.
|
* **`osal.processinfo_get(pid int) !ProcessInfo`**: Get detailed information for a specific process.
|
||||||
* **`osal.processinfo_get_byname(name string) ![]ProcessInfo`**: Get info for processes matching a name.
|
* **`osal.processinfo_get_byname(name string) ![]ProcessInfo`**: Get info for processes matching a name.
|
||||||
* **`osal.process_exists(pid int) bool`**: Check if a process exists by PID.
|
* **`osal.process_exists(pid int) bool`**: Check if a process exists by PID.
|
||||||
* **`osal.processinfo_with_children(pid int) !ProcessMap`**: Get a process and its children.
|
* **`osal.processinfo_with_children(pid int) !ProcessMap`**: Get a process and its children.
|
||||||
* **`osal.processinfo_children(pid int) !ProcessMap`**: Get children of a process.
|
* **`osal.processinfo_children(pid int) !ProcessMap`**: Get children of a process.
|
||||||
* **`osal.process_kill_recursive(args: ProcessKillArgs) !`**: Kill a process and its children.
|
* **`osal.process_kill_recursive(args: ProcessKillArgs) !`**: Kill a process and its children.
|
||||||
* **Key Parameters**: `name` (string), `pid` (int).
|
* **Key Parameters**: `name` (string), `pid` (int).
|
||||||
* **`osal.whoami() !string`**: Return the current username.
|
* **`osal.whoami() !string`**: Return the current username.
|
||||||
* **`osal.platform() !PlatformType`**: Identify the operating system.
|
* **`osal.platform() !PlatformType`**: Identify the operating system.
|
||||||
* **`osal.cputype() !CPUType`**: Identify the CPU architecture.
|
* **`osal.cputype() !CPUType`**: Identify the CPU architecture.
|
||||||
* **`osal.hostname() !string`**: Get system hostname.
|
* **`osal.hostname() !string`**: Get system hostname.
|
||||||
* **`osal.sleep(duration int)`**: Pause execution for a specified duration.
|
* **`osal.sleep(duration int)`**: Pause execution for a specified duration.
|
||||||
* **`osal.download(args: DownloadArgs) !pathlib.Path`**: Download a file from a URL.
|
* **`osal.download(args: DownloadArgs) !pathlib.Path`**: Download a file from a URL.
|
||||||
* `pathlib.Path` is from `freeflowuniverse.herolib.core.pathlib`
|
* `pathlib.Path` is from `incubaid.herolib.core.pathlib`
|
||||||
* **Key Parameters**: `url` (string), `dest` (string), `timeout` (int), `retry` (int).
|
* **Key Parameters**: `url` (string), `dest` (string), `timeout` (int), `retry` (int).
|
||||||
* **`osal.user_exists(username string) bool`**: Check if a user exists.
|
* **`osal.user_exists(username string) bool`**: Check if a user exists.
|
||||||
* **`osal.user_id_get(username string) !int`**: Get user ID.
|
* **`osal.user_id_get(username string) !int`**: Get user ID.
|
||||||
* **`osal.user_add(args: UserArgs) !int`**: Add a user.
|
* **`osal.user_add(args: UserArgs) !int`**: Add a user.
|
||||||
* **Key Parameters**: `name` (string).
|
* **Key Parameters**: `name` (string).
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
The `OurTime` module in V provides flexible time handling, supporting relative and absolute time formats, Unix timestamps, and formatting utilities.
|
The `OurTime` module in V provides flexible time handling, supporting relative and absolute time formats, Unix timestamps, and formatting utilities.
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
- Create time objects from strings or current time
|
- Create time objects from strings or current time
|
||||||
- Relative time expressions (e.g., `+1h`, `-2d`)
|
- Relative time expressions (e.g., `+1h`, `-2d`)
|
||||||
- Absolute time formats (e.g., `YYYY-MM-DD HH:mm:ss`)
|
- Absolute time formats (e.g., `YYYY-MM-DD HH:mm:ss`)
|
||||||
@@ -12,7 +13,7 @@ The `OurTime` module in V provides flexible time handling, supporting relative a
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
|
|
||||||
// Current time
|
// Current time
|
||||||
mut t := ourtime.now()
|
mut t := ourtime.now()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ This document details the `paramsparser` module, essential for handling paramete
|
|||||||
## Obtaining a `paramsparser` Instance
|
## Obtaining a `paramsparser` Instance
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.data.paramsparser
|
import incubaid.herolib.data.paramsparser
|
||||||
|
|
||||||
// Create new params from a string
|
// Create new params from a string
|
||||||
params := paramsparser.new("color:red size:'large' priority:1 enable:true")!
|
params := paramsparser.new("color:red size:'large' priority:1 enable:true")!
|
||||||
@@ -19,12 +19,13 @@ params.set("color", "red")
|
|||||||
|
|
||||||
The parser supports various input formats:
|
The parser supports various input formats:
|
||||||
|
|
||||||
1. **Key-value pairs**: `key:value`
|
1. **Key-value pairs**: `key:value`
|
||||||
2. **Quoted values**: `key:'value with spaces'` (single or double quotes)
|
2. **Quoted values**: `key:'value with spaces'` (single or double quotes)
|
||||||
3. **Arguments without keys**: `arg1 arg2` (accessed by index)
|
3. **Arguments without keys**: `arg1 arg2` (accessed by index)
|
||||||
4. **Comments**: `// this is a comment` (ignored during parsing)
|
4. **Comments**: `// this is a comment` (ignored during parsing)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := "name:'John Doe' age:30 active:true // user details"
|
text := "name:'John Doe' age:30 active:true // user details"
|
||||||
params := paramsparser.new(text)!
|
params := paramsparser.new(text)!
|
||||||
@@ -36,74 +37,74 @@ The `paramsparser` module provides a comprehensive set of methods for retrieving
|
|||||||
|
|
||||||
### Basic Retrieval
|
### Basic Retrieval
|
||||||
|
|
||||||
- `get(key string) !string`: Retrieves a string value by key. Returns an error if the key does not exist.
|
- `get(key string) !string`: Retrieves a string value by key. Returns an error if the key does not exist.
|
||||||
- `get_default(key string, defval string) !string`: Retrieves a string value by key, or returns `defval` if the key is not found.
|
- `get_default(key string, defval string) !string`: Retrieves a string value by key, or returns `defval` if the key is not found.
|
||||||
- `exists(key string) bool`: Checks if a keyword argument (`key:value`) exists.
|
- `exists(key string) bool`: Checks if a keyword argument (`key:value`) exists.
|
||||||
- `exists_arg(key string) bool`: Checks if an argument (value without a key) exists.
|
- `exists_arg(key string) bool`: Checks if an argument (value without a key) exists.
|
||||||
|
|
||||||
### Argument Retrieval (Positional)
|
### Argument Retrieval (Positional)
|
||||||
|
|
||||||
- `get_arg(nr int) !string`: Retrieves an argument by its 0-based index. Returns an error if the index is out of bounds.
|
- `get_arg(nr int) !string`: Retrieves an argument by its 0-based index. Returns an error if the index is out of bounds.
|
||||||
- `get_arg_default(nr int, defval string) !string`: Retrieves an argument by index, or returns `defval` if the index is out of bounds.
|
- `get_arg_default(nr int, defval string) !string`: Retrieves an argument by index, or returns `defval` if the index is out of bounds.
|
||||||
|
|
||||||
### Type-Specific Retrieval
|
### Type-Specific Retrieval
|
||||||
|
|
||||||
- `get_int(key string) !int`: Converts and retrieves an integer (int32).
|
- `get_int(key string) !int`: Converts and retrieves an integer (int32).
|
||||||
- `get_int_default(key string, defval int) !int`: Retrieves an integer with a default.
|
- `get_int_default(key string, defval int) !int`: Retrieves an integer with a default.
|
||||||
- `get_u32(key string) !u32`: Converts and retrieves an unsigned 32-bit integer.
|
- `get_u32(key string) !u32`: Converts and retrieves an unsigned 32-bit integer.
|
||||||
- `get_u32_default(key string, defval u32) !u32`: Retrieves a u32 with a default.
|
- `get_u32_default(key string, defval u32) !u32`: Retrieves a u32 with a default.
|
||||||
- `get_u64(key string) !u64`: Converts and retrieves an unsigned 64-bit integer.
|
- `get_u64(key string) !u64`: Converts and retrieves an unsigned 64-bit integer.
|
||||||
- `get_u64_default(key string, defval u64) !u64`: Retrieves a u64 with a default.
|
- `get_u64_default(key string, defval u64) !u64`: Retrieves a u64 with a default.
|
||||||
- `get_u8(key string) !u8`: Converts and retrieves an unsigned 8-bit integer.
|
- `get_u8(key string) !u8`: Converts and retrieves an unsigned 8-bit integer.
|
||||||
- `get_u8_default(key string, defval u8) !u8`: Retrieves a u8 with a default.
|
- `get_u8_default(key string, defval u8) !u8`: Retrieves a u8 with a default.
|
||||||
- `get_float(key string) !f64`: Converts and retrieves a 64-bit float.
|
- `get_float(key string) !f64`: Converts and retrieves a 64-bit float.
|
||||||
- `get_float_default(key string, defval f64) !f64`: Retrieves a float with a default.
|
- `get_float_default(key string, defval f64) !f64`: Retrieves a float with a default.
|
||||||
- `get_percentage(key string) !f64`: Converts a percentage string (e.g., "80%") to a float (0.8).
|
- `get_percentage(key string) !f64`: Converts a percentage string (e.g., "80%") to a float (0.8).
|
||||||
- `get_percentage_default(key string, defval string) !f64`: Retrieves a percentage with a default.
|
- `get_percentage_default(key string, defval string) !f64`: Retrieves a percentage with a default.
|
||||||
|
|
||||||
### Boolean Retrieval
|
### Boolean Retrieval
|
||||||
|
|
||||||
- `get_default_true(key string) bool`: Returns `true` if the value is empty, "1", "true", "y", or "yes". Otherwise `false`.
|
- `get_default_true(key string) bool`: Returns `true` if the value is empty, "1", "true", "y", or "yes". Otherwise `false`.
|
||||||
- `get_default_false(key string) bool`: Returns `false` if the value is empty, "0", "false", "n", or "no". Otherwise `true`.
|
- `get_default_false(key string) bool`: Returns `false` if the value is empty, "0", "false", "n", or "no". Otherwise `true`.
|
||||||
|
|
||||||
### List Retrieval
|
### List Retrieval
|
||||||
|
|
||||||
Lists are typically comma-separated strings (e.g., `users: "john,jane,bob"`).
|
Lists are typically comma-separated strings (e.g., `users: "john,jane,bob"`).
|
||||||
|
|
||||||
- `get_list(key string) ![]string`: Retrieves a list of strings.
|
- `get_list(key string) ![]string`: Retrieves a list of strings.
|
||||||
- `get_list_default(key string, def []string) ![]string`: Retrieves a list of strings with a default.
|
- `get_list_default(key string, def []string) ![]string`: Retrieves a list of strings with a default.
|
||||||
- `get_list_int(key string) ![]int`: Retrieves a list of integers.
|
- `get_list_int(key string) ![]int`: Retrieves a list of integers.
|
||||||
- `get_list_int_default(key string, def []int) []int`: Retrieves a list of integers with a default.
|
- `get_list_int_default(key string, def []int) []int`: Retrieves a list of integers with a default.
|
||||||
- `get_list_f32(key string) ![]f32`: Retrieves a list of 32-bit floats.
|
- `get_list_f32(key string) ![]f32`: Retrieves a list of 32-bit floats.
|
||||||
- `get_list_f32_default(key string, def []f32) []f32`: Retrieves a list of f32 with a default.
|
- `get_list_f32_default(key string, def []f32) []f32`: Retrieves a list of f32 with a default.
|
||||||
- `get_list_f64(key string) ![]f64`: Retrieves a list of 64-bit floats.
|
- `get_list_f64(key string) ![]f64`: Retrieves a list of 64-bit floats.
|
||||||
- `get_list_f64_default(key string, def []f64) []f64`: Retrieves a list of f64 with a default.
|
- `get_list_f64_default(key string, def []f64) []f64`: Retrieves a list of f64 with a default.
|
||||||
- `get_list_i8(key string) ![]i8`: Retrieves a list of 8-bit signed integers.
|
- `get_list_i8(key string) ![]i8`: Retrieves a list of 8-bit signed integers.
|
||||||
- `get_list_i8_default(key string, def []i8) []i8`: Retrieves a list of i8 with a default.
|
- `get_list_i8_default(key string, def []i8) []i8`: Retrieves a list of i8 with a default.
|
||||||
- `get_list_i16(key string) ![]i16`: Retrieves a list of 16-bit signed integers.
|
- `get_list_i16(key string) ![]i16`: Retrieves a list of 16-bit signed integers.
|
||||||
- `get_list_i16_default(key string, def []i16) []i16`: Retrieves a list of i16 with a default.
|
- `get_list_i16_default(key string, def []i16) []i16`: Retrieves a list of i16 with a default.
|
||||||
- `get_list_i64(key string) ![]i64`: Retrieves a list of 64-bit signed integers.
|
- `get_list_i64(key string) ![]i64`: Retrieves a list of 64-bit signed integers.
|
||||||
- `get_list_i64_default(key string, def []i64) []i64`: Retrieves a list of i64 with a default.
|
- `get_list_i64_default(key string, def []i64) []i64`: Retrieves a list of i64 with a default.
|
||||||
- `get_list_u16(key string) ![]u16`: Retrieves a list of 16-bit unsigned integers.
|
- `get_list_u16(key string) ![]u16`: Retrieves a list of 16-bit unsigned integers.
|
||||||
- `get_list_u16_default(key string, def []u16) []u16`: Retrieves a list of u16 with a default.
|
- `get_list_u16_default(key string, def []u16) []u16`: Retrieves a list of u16 with a default.
|
||||||
- `get_list_u32(key string) ![]u32`: Retrieves a list of 32-bit unsigned integers.
|
- `get_list_u32(key string) ![]u32`: Retrieves a list of 32-bit unsigned integers.
|
||||||
- `get_list_u32_default(key string, def []u32) []u32`: Retrieves a list of u32 with a default.
|
- `get_list_u32_default(key string, def []u32) []u32`: Retrieves a list of u32 with a default.
|
||||||
- `get_list_u64(key string) ![]u64`: Retrieves a list of 64-bit unsigned integers.
|
- `get_list_u64(key string) ![]u64`: Retrieves a list of 64-bit unsigned integers.
|
||||||
- `get_list_u64_default(key string, def []u64) []u64`: Retrieves a list of u64 with a default.
|
- `get_list_u64_default(key string, def []u64) []u64`: Retrieves a list of u64 with a default.
|
||||||
- `get_list_namefix(key string) ![]string`: Retrieves a list of strings, normalizing each item (e.g., "My Name" -> "my_name").
|
- `get_list_namefix(key string) ![]string`: Retrieves a list of strings, normalizing each item (e.g., "My Name" -> "my_name").
|
||||||
- `get_list_namefix_default(key string, def []string) ![]string`: Retrieves a list of name-fixed strings with a default.
|
- `get_list_namefix_default(key string, def []string) ![]string`: Retrieves a list of name-fixed strings with a default.
|
||||||
|
|
||||||
### Specialized Retrieval
|
### Specialized Retrieval
|
||||||
|
|
||||||
- `get_map() map[string]string`: Returns all parameters as a map.
|
- `get_map() map[string]string`: Returns all parameters as a map.
|
||||||
- `get_path(key string) !string`: Retrieves a path string.
|
- `get_path(key string) !string`: Retrieves a path string.
|
||||||
- `get_path_create(key string) !string`: Retrieves a path string, creating the directory if it doesn't exist.
|
- `get_path_create(key string) !string`: Retrieves a path string, creating the directory if it doesn't exist.
|
||||||
- `get_from_hashmap(key string, defval string, hashmap map[string]string) !string`: Retrieves a value from a provided hashmap based on the parameter's value.
|
- `get_from_hashmap(key string, defval string, hashmap map[string]string) !string`: Retrieves a value from a provided hashmap based on the parameter's value.
|
||||||
- `get_storagecapacity_in_bytes(key string) !u64`: Converts storage capacity strings (e.g., "10 GB", "500 MB") to bytes (u64).
|
- `get_storagecapacity_in_bytes(key string) !u64`: Converts storage capacity strings (e.g., "10 GB", "500 MB") to bytes (u64).
|
||||||
- `get_storagecapacity_in_bytes_default(key string, defval u64) !u64`: Retrieves storage capacity in bytes with a default.
|
- `get_storagecapacity_in_bytes_default(key string, defval u64) !u64`: Retrieves storage capacity in bytes with a default.
|
||||||
- `get_storagecapacity_in_gigabytes(key string) !u64`: Converts storage capacity strings to gigabytes (u64).
|
- `get_storagecapacity_in_gigabytes(key string) !u64`: Converts storage capacity strings to gigabytes (u64).
|
||||||
- `get_time(key string) !ourtime.OurTime`: Parses a time string (relative or absolute) into an `ourtime.OurTime` object.
|
- `get_time(key string) !ourtime.OurTime`: Parses a time string (relative or absolute) into an `ourtime.OurTime` object.
|
||||||
- `get_time_default(key string, defval ourtime.OurTime) !ourtime.OurTime`: Retrieves time with a default.
|
- `get_time_default(key string, defval ourtime.OurTime) !ourtime.OurTime`: Retrieves time with a default.
|
||||||
- `get_time_interval(key string) !Duration`: Parses a time interval string into a `Duration` object.
|
- `get_time_interval(key string) !Duration`: Parses a time interval string into a `Duration` object.
|
||||||
- `get_timestamp(key string) !Duration`: Parses a timestamp string into a `Duration` object.
|
- `get_timestamp(key string) !Duration`: Parses a timestamp string into a `Duration` object.
|
||||||
- `get_timestamp_default(key string, defval Duration) !Duration`: Retrieves a timestamp with a default.
|
- `get_timestamp_default(key string, defval Duration) !Duration`: Retrieves a timestamp with a default.
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ The pathlib module provides a comprehensive interface for handling file system o
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
### Importing pathlib
|
### Importing pathlib
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
```
|
```
|
||||||
|
|
||||||
### Creating Path Objects
|
### Creating Path Objects
|
||||||
@@ -33,6 +34,7 @@ mut dir_path := pathlib.get("path/to/directory")
|
|||||||
if you know in advance if you expect a dir or file its better to use `pathlib.get_dir(path:...,create:true)` or `pathlib.get_file(path:...,create:true)`.
|
if you know in advance if you expect a dir or file its better to use `pathlib.get_dir(path:...,create:true)` or `pathlib.get_file(path:...,create:true)`.
|
||||||
|
|
||||||
### Basic Path Operations
|
### Basic Path Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Get absolute path
|
// Get absolute path
|
||||||
abs_path := file_path.absolute()
|
abs_path := file_path.absolute()
|
||||||
@@ -49,6 +51,7 @@ if file_path.exists() {
|
|||||||
## Path Properties and Methods
|
## Path Properties and Methods
|
||||||
|
|
||||||
### Path Types
|
### Path Types
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Check if path is a file
|
// Check if path is a file
|
||||||
if file_path.is_file() {
|
if file_path.is_file() {
|
||||||
@@ -67,6 +70,7 @@ if file_path.is_link() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Path Normalization
|
### Path Normalization
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Normalize path (remove extra slashes, resolve . and ..)
|
// Normalize path (remove extra slashes, resolve . and ..)
|
||||||
normalized_path := file_path.path_normalize()
|
normalized_path := file_path.path_normalize()
|
||||||
@@ -81,6 +85,7 @@ name_no_ext := file_path.name_no_ext()
|
|||||||
## File and Directory Operations
|
## File and Directory Operations
|
||||||
|
|
||||||
### File Operations
|
### File Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Write to file
|
// Write to file
|
||||||
file_path.write("Content to write")!
|
file_path.write("Content to write")!
|
||||||
@@ -93,6 +98,7 @@ file_path.delete()!
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Directory Operations
|
### Directory Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Create directory
|
// Create directory
|
||||||
mut dir := pathlib.get_dir(
|
mut dir := pathlib.get_dir(
|
||||||
@@ -108,6 +114,7 @@ dir.delete()!
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Symlink Operations
|
### Symlink Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Create symlink
|
// Create symlink
|
||||||
file_path.link("path/to/symlink", delete_exists: true)!
|
file_path.link("path/to/symlink", delete_exists: true)!
|
||||||
@@ -119,12 +126,14 @@ real_path := file_path.realpath()
|
|||||||
## Advanced Operations
|
## Advanced Operations
|
||||||
|
|
||||||
### Path Copying
|
### Path Copying
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Copy file to destination
|
// Copy file to destination
|
||||||
file_path.copy(dest: "path/to/destination")!
|
file_path.copy(dest: "path/to/destination")!
|
||||||
```
|
```
|
||||||
|
|
||||||
### Recursive Operations
|
### Recursive Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// List directory recursively
|
// List directory recursively
|
||||||
mut recursive_list := dir.list(recursive: true)!
|
mut recursive_list := dir.list(recursive: true)!
|
||||||
@@ -134,6 +143,7 @@ dir.delete()!
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Path Filtering
|
### Path Filtering
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// List files matching pattern
|
// List files matching pattern
|
||||||
mut filtered_list := dir.list(
|
mut filtered_list := dir.list(
|
||||||
@@ -145,6 +155,7 @@ mut filtered_list := dir.list(
|
|||||||
## Best Practices
|
## Best Practices
|
||||||
|
|
||||||
### Error Handling
|
### Error Handling
|
||||||
|
|
||||||
```v
|
```v
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
// Safe to operate
|
// Safe to operate
|
||||||
@@ -152,4 +163,3 @@ if file_path.exists() {
|
|||||||
// Handle missing file
|
// Handle missing file
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ The `redisclient` module in Herolib provides a comprehensive client for interact
|
|||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
- **Direct Redis Commands**: Access to a wide range of Redis commands (strings, hashes, lists, keys, etc.).
|
- **Direct Redis Commands**: Access to a wide range of Redis commands (strings, hashes, lists, keys, etc.).
|
||||||
- **Caching**: Built-in caching mechanism with namespace support and expiration.
|
- **Caching**: Built-in caching mechanism with namespace support and expiration.
|
||||||
- **Queues**: Simple queue implementation using Redis lists.
|
- **Queues**: Simple queue implementation using Redis lists.
|
||||||
- **RPC**: Remote Procedure Call (RPC) functionality over Redis queues for inter-service communication.
|
- **RPC**: Remote Procedure Call (RPC) functionality over Redis queues for inter-service communication.
|
||||||
|
|
||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
To get a Redis client instance, use `redisclient.core_get()`. By default, it connects to `127.0.0.1:6379`. You can specify a different address and port using the `RedisURL` struct.
|
To get a Redis client instance, use `redisclient.core_get()`. By default, it connects to `127.0.0.1:6379`. You can specify a different address and port using the `RedisURL` struct.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.redisclient
|
import incubaid.herolib.core.redisclient
|
||||||
|
|
||||||
// Connect to default Redis instance (127.0.0.1:6379)
|
// Connect to default Redis instance (127.0.0.1:6379)
|
||||||
mut redis := redisclient.core_get()!
|
mut redis := redisclient.core_get()!
|
||||||
@@ -42,13 +42,13 @@ The `Redis` object provides methods for most standard Redis commands. Here are s
|
|||||||
|
|
||||||
### String Commands
|
### String Commands
|
||||||
|
|
||||||
- `set(key string, value string) !`: Sets the string value of a key.
|
- `set(key string, value string) !`: Sets the string value of a key.
|
||||||
- `get(key string) !string`: Gets the string value of a key.
|
- `get(key string) !string`: Gets the string value of a key.
|
||||||
- `set_ex(key string, value string, ex string) !`: Sets a key with an expiration time in seconds.
|
- `set_ex(key string, value string, ex string) !`: Sets a key with an expiration time in seconds.
|
||||||
- `incr(key string) !int`: Increments the integer value of a key by one.
|
- `incr(key string) !int`: Increments the integer value of a key by one.
|
||||||
- `decr(key string) !int`: Decrements the integer value of a key by one.
|
- `decr(key string) !int`: Decrements the integer value of a key by one.
|
||||||
- `append(key string, value string) !int`: Appends a value to a key.
|
- `append(key string, value string) !int`: Appends a value to a key.
|
||||||
- `strlen(key string) !int`: Gets the length of the value stored in a key.
|
- `strlen(key string) !int`: Gets the length of the value stored in a key.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
redis.set('counter', '10')!
|
redis.set('counter', '10')!
|
||||||
@@ -58,11 +58,11 @@ val := redis.get('counter')! // "11"
|
|||||||
|
|
||||||
### Hash Commands
|
### Hash Commands
|
||||||
|
|
||||||
- `hset(key string, skey string, value string) !`: Sets the string value of a hash field.
|
- `hset(key string, skey string, value string) !`: Sets the string value of a hash field.
|
||||||
- `hget(key string, skey string) !string`: Gets the value of a hash field.
|
- `hget(key string, skey string) !string`: Gets the value of a hash field.
|
||||||
- `hgetall(key string) !map[string]string`: Gets all fields and values in a hash.
|
- `hgetall(key string) !map[string]string`: Gets all fields and values in a hash.
|
||||||
- `hexists(key string, skey string) !bool`: Checks if a hash field exists.
|
- `hexists(key string, skey string) !bool`: Checks if a hash field exists.
|
||||||
- `hdel(key string, skey string) !int`: Deletes one or more hash fields.
|
- `hdel(key string, skey string) !int`: Deletes one or more hash fields.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
redis.hset('user:1', 'name', 'John Doe')!
|
redis.hset('user:1', 'name', 'John Doe')!
|
||||||
@@ -73,12 +73,12 @@ user_data := redis.hgetall('user:1')! // map['name':'John Doe', 'email':'john@ex
|
|||||||
|
|
||||||
### List Commands
|
### List Commands
|
||||||
|
|
||||||
- `lpush(key string, element string) !int`: Inserts all specified values at the head of the list stored at key.
|
- `lpush(key string, element string) !int`: Inserts all specified values at the head of the list stored at key.
|
||||||
- `rpush(key string, element string) !int`: Inserts all specified values at the tail of the list stored at key.
|
- `rpush(key string, element string) !int`: Inserts all specified values at the tail of the list stored at key.
|
||||||
- `lpop(key string) !string`: Removes and returns the first element of the list stored at key.
|
- `lpop(key string) !string`: Removes and returns the first element of the list stored at key.
|
||||||
- `rpop(key string) !string`: Removes and returns the last element of the list stored at key.
|
- `rpop(key string) !string`: Removes and returns the last element of the list stored at key.
|
||||||
- `llen(key string) !int`: Gets the length of a list.
|
- `llen(key string) !int`: Gets the length of a list.
|
||||||
- `lrange(key string, start int, end int) ![]resp.RValue`: Gets a range of elements from a list.
|
- `lrange(key string, start int, end int) ![]resp.RValue`: Gets a range of elements from a list.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
redis.lpush('mylist', 'item1')!
|
redis.lpush('mylist', 'item1')!
|
||||||
@@ -88,8 +88,8 @@ first_item := redis.lpop('mylist')! // "item1"
|
|||||||
|
|
||||||
### Set Commands
|
### Set Commands
|
||||||
|
|
||||||
- `sadd(key string, members []string) !int`: Adds the specified members to the set stored at key.
|
- `sadd(key string, members []string) !int`: Adds the specified members to the set stored at key.
|
||||||
- `smismember(key string, members []string) ![]int`: Returns if member is a member of the set stored at key.
|
- `smismember(key string, members []string) ![]int`: Returns if member is a member of the set stored at key.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
redis.sadd('myset', ['member1', 'member2'])!
|
redis.sadd('myset', ['member1', 'member2'])!
|
||||||
@@ -98,13 +98,13 @@ is_member := redis.smismember('myset', ['member1', 'member3'])! // [1, 0]
|
|||||||
|
|
||||||
### Key Management
|
### Key Management
|
||||||
|
|
||||||
- `keys(pattern string) ![]string`: Finds all keys matching the given pattern.
|
- `keys(pattern string) ![]string`: Finds all keys matching the given pattern.
|
||||||
- `del(key string) !int`: Deletes a key.
|
- `del(key string) !int`: Deletes a key.
|
||||||
- `expire(key string, seconds int) !int`: Sets a key's time to live in seconds.
|
- `expire(key string, seconds int) !int`: Sets a key's time to live in seconds.
|
||||||
- `ttl(key string) !int`: Gets the time to live for a key in seconds.
|
- `ttl(key string) !int`: Gets the time to live for a key in seconds.
|
||||||
- `flushall() !`: Deletes all the keys of all the existing databases.
|
- `flushall() !`: Deletes all the keys of all the existing databases.
|
||||||
- `flushdb() !`: Deletes all the keys of the currently selected database.
|
- `flushdb() !`: Deletes all the keys of the currently selected database.
|
||||||
- `selectdb(database int) !`: Changes the selected database.
|
- `selectdb(database int) !`: Changes the selected database.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
redis.set('temp_key', 'value')!
|
redis.set('temp_key', 'value')!
|
||||||
@@ -116,7 +116,7 @@ redis.expire('temp_key', 60)! // Expires in 60 seconds
|
|||||||
The `RedisCache` struct provides a convenient way to implement caching using Redis.
|
The `RedisCache` struct provides a convenient way to implement caching using Redis.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.redisclient
|
import incubaid.herolib.core.redisclient
|
||||||
|
|
||||||
mut redis := redisclient.core_get()!
|
mut redis := redisclient.core_get()!
|
||||||
mut cache := redis.cache('my_app_cache')
|
mut cache := redis.cache('my_app_cache')
|
||||||
@@ -145,7 +145,7 @@ cache.reset()!
|
|||||||
The `RedisQueue` struct provides a simple queue mechanism using Redis lists.
|
The `RedisQueue` struct provides a simple queue mechanism using Redis lists.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.redisclient
|
import incubaid.herolib.core.redisclient
|
||||||
import time
|
import time
|
||||||
|
|
||||||
mut redis := redisclient.core_get()!
|
mut redis := redisclient.core_get()!
|
||||||
@@ -169,7 +169,7 @@ task2 := my_queue.pop()!
|
|||||||
The `RedisRpc` struct enables Remote Procedure Call (RPC) over Redis, allowing services to communicate by sending messages to queues and waiting for responses.
|
The `RedisRpc` struct enables Remote Procedure Call (RPC) over Redis, allowing services to communicate by sending messages to queues and waiting for responses.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.redisclient
|
import incubaid.herolib.core.redisclient
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|||||||
@@ -2,96 +2,124 @@
|
|||||||
|
|
||||||
The `texttools` module provides a comprehensive set of utilities for text manipulation and processing.
|
The `texttools` module provides a comprehensive set of utilities for text manipulation and processing.
|
||||||
|
|
||||||
## Functions and Examples:
|
## Functions and Examples
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.texttools
|
import incubaid.herolib.core.texttools
|
||||||
|
|
||||||
assert hello_world == texttools.name_fix("Hello World!")
|
assert hello_world == texttools.name_fix("Hello World!")
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Name/Path Processing
|
### Name/Path Processing
|
||||||
* `name_fix(name string) string`: Normalizes filenames and paths.
|
|
||||||
* `name_fix_keepspace(name string) !string`: Like name_fix but preserves spaces.
|
* `name_fix(name string) string`: Normalizes filenames and paths.
|
||||||
* `name_fix_no_ext(name_ string) string`: Removes file extension.
|
* `name_fix_keepspace(name string) !string`: Like name_fix but preserves spaces.
|
||||||
* `name_fix_snake_to_pascal(name string) string`: Converts snake_case to PascalCase.
|
* `name_fix_no_ext(name_ string) string`: Removes file extension.
|
||||||
|
* `name_fix_snake_to_pascal(name string) string`: Converts snake_case to PascalCase.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
name := texttools.name_fix_snake_to_pascal("hello_world") // Result: "HelloWorld"
|
name := texttools.name_fix_snake_to_pascal("hello_world") // Result: "HelloWorld"
|
||||||
```
|
```
|
||||||
* `snake_case(name string) string`: Converts PascalCase to snake_case.
|
|
||||||
|
* `snake_case(name string) string`: Converts PascalCase to snake_case.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
name := texttools.snake_case("HelloWorld") // Result: "hello_world"
|
name := texttools.snake_case("HelloWorld") // Result: "hello_world"
|
||||||
```
|
```
|
||||||
* `name_split(name string) !(string, string)`: Splits name into site and page components.
|
|
||||||
|
|
||||||
|
* `name_split(name string) !(string, string)`: Splits name into site and page components.
|
||||||
|
|
||||||
### Text Cleaning
|
### Text Cleaning
|
||||||
* `name_clean(r string) string`: Normalizes names by removing special characters.
|
|
||||||
|
* `name_clean(r string) string`: Normalizes names by removing special characters.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
name := texttools.name_clean("Hello@World!") // Result: "HelloWorld"
|
name := texttools.name_clean("Hello@World!") // Result: "HelloWorld"
|
||||||
```
|
```
|
||||||
* `ascii_clean(r string) string`: Removes all non-ASCII characters.
|
|
||||||
* `remove_empty_lines(text string) string`: Removes empty lines from text.
|
* `ascii_clean(r string) string`: Removes all non-ASCII characters.
|
||||||
|
* `remove_empty_lines(text string) string`: Removes empty lines from text.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := texttools.remove_empty_lines("line1\n\nline2\n\n\nline3") // Result: "line1\nline2\nline3"
|
text := texttools.remove_empty_lines("line1\n\nline2\n\n\nline3") // Result: "line1\nline2\nline3"
|
||||||
```
|
```
|
||||||
* `remove_double_lines(text string) string`: Removes consecutive empty lines.
|
|
||||||
* `remove_empty_js_blocks(text string) string`: Removes empty code blocks (```...```).
|
* `remove_double_lines(text string) string`: Removes consecutive empty lines.
|
||||||
|
* `remove_empty_js_blocks(text string) string`: Removes empty code blocks (```...```).
|
||||||
|
|
||||||
### Command Line Parsing
|
### Command Line Parsing
|
||||||
* `cmd_line_args_parser(text string) ![]string`: Parses command line arguments with support for quotes and escaping.
|
|
||||||
|
* `cmd_line_args_parser(text string) ![]string`: Parses command line arguments with support for quotes and escaping.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
args := texttools.cmd_line_args_parser("'arg with spaces' --flag=value") // Result: ['arg with spaces', '--flag=value']
|
args := texttools.cmd_line_args_parser("'arg with spaces' --flag=value") // Result: ['arg with spaces', '--flag=value']
|
||||||
```
|
```
|
||||||
* `text_remove_quotes(text string) string`: Removes quoted sections from text.
|
|
||||||
* `check_exists_outside_quotes(text string, items []string) bool`: Checks if items exist in text outside of quotes.
|
* `text_remove_quotes(text string) string`: Removes quoted sections from text.
|
||||||
|
* `check_exists_outside_quotes(text string, items []string) bool`: Checks if items exist in text outside of quotes.
|
||||||
|
|
||||||
### Text Expansion
|
### Text Expansion
|
||||||
* `expand(txt_ string, l int, expand_with string) string`: Expands text to a specified length with a given character.
|
|
||||||
|
* `expand(txt_ string, l int, expand_with string) string`: Expands text to a specified length with a given character.
|
||||||
|
|
||||||
### Indentation
|
### Indentation
|
||||||
* `indent(text string, prefix string) string`: Adds indentation prefix to each line.
|
|
||||||
|
* `indent(text string, prefix string) string`: Adds indentation prefix to each line.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := texttools.indent("line1\nline2", " ") // Result: " line1\n line2\n"
|
text := texttools.indent("line1\nline2", " ") // Result: " line1\n line2\n"
|
||||||
```
|
```
|
||||||
* `dedent(text string) string`: Removes common leading whitespace from every line.
|
|
||||||
|
* `dedent(text string) string`: Removes common leading whitespace from every line.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := texttools.dedent(" line1\n line2") // Result: "line1\nline2"
|
text := texttools.dedent(" line1\n line2") // Result: "line1\nline2"
|
||||||
```
|
```
|
||||||
|
|
||||||
### String Validation
|
### String Validation
|
||||||
* `is_int(text string) bool`: Checks if text contains only digits.
|
|
||||||
* `is_upper_text(text string) bool`: Checks if text contains only uppercase letters.
|
* `is_int(text string) bool`: Checks if text contains only digits.
|
||||||
|
* `is_upper_text(text string) bool`: Checks if text contains only uppercase letters.
|
||||||
|
|
||||||
### Multiline Processing
|
### Multiline Processing
|
||||||
* `multiline_to_single(text string) !string`: Converts multiline text to a single line with proper escaping.
|
|
||||||
|
* `multiline_to_single(text string) !string`: Converts multiline text to a single line with proper escaping.
|
||||||
|
|
||||||
### Text Splitting
|
### Text Splitting
|
||||||
* `split_smart(t string, delimiter_ string) []string`: Intelligent string splitting that respects quotes.
|
|
||||||
|
* `split_smart(t string, delimiter_ string) []string`: Intelligent string splitting that respects quotes.
|
||||||
|
|
||||||
### Tokenization
|
### Tokenization
|
||||||
* `tokenize(text_ string) TokenizerResult`: Tokenizes text into meaningful parts.
|
|
||||||
* `text_token_replace(text string, tofind string, replacewith string) !string`: Replaces tokens in text.
|
* `tokenize(text_ string) TokenizerResult`: Tokenizes text into meaningful parts.
|
||||||
|
* `text_token_replace(text string, tofind string, replacewith string) !string`: Replaces tokens in text.
|
||||||
|
|
||||||
### Version Parsing
|
### Version Parsing
|
||||||
* `version(text_ string) int`: Converts version strings to comparable integers.
|
|
||||||
|
* `version(text_ string) int`: Converts version strings to comparable integers.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
ver := texttools.version("v0.4.36") // Result: 4036
|
ver := texttools.version("v0.4.36") // Result: 4036
|
||||||
ver = texttools.version("v1.4.36") // Result: 1004036
|
ver = texttools.version("v1.4.36") // Result: 1004036
|
||||||
```
|
```
|
||||||
|
|
||||||
### Formatting
|
### Formatting
|
||||||
* `format_rfc1123(t time.Time) string`: Formats a time.Time object into RFC 1123 format.
|
|
||||||
|
|
||||||
|
* `format_rfc1123(t time.Time) string`: Formats a time.Time object into RFC 1123 format.
|
||||||
|
|
||||||
### Array Operations
|
### Array Operations
|
||||||
* `to_array(r string) []string`: Converts a comma or newline separated list to an array of strings.
|
|
||||||
|
* `to_array(r string) []string`: Converts a comma or newline separated list to an array of strings.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := "item1,item2,item3"
|
text := "item1,item2,item3"
|
||||||
array := texttools.to_array(text) // Result: ['item1', 'item2', 'item3']
|
array := texttools.to_array(text) // Result: ['item1', 'item2', 'item3']
|
||||||
```
|
```
|
||||||
* `to_array_int(r string) []int`: Converts a text list to an array of integers.
|
|
||||||
* `to_map(mapstring string, line string, delimiter_ string) map[string]string`: Intelligent mapping of a line to a map based on a template.
|
* `to_array_int(r string) []int`: Converts a text list to an array of integers.
|
||||||
|
* `to_map(mapstring string, line string, delimiter_ string) map[string]string`: Intelligent mapping of a line to a map based on a template.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
r := texttools.to_map("name,-,-,-,-,pid,-,-,-,-,path",
|
r := texttools.to_map("name,-,-,-,-,pid,-,-,-,-,path",
|
||||||
"root 304 0.0 0.0 408185328 1360 ?? S 16Dec23 0:34.06 /usr/sbin/distnoted")
|
"root 304 0.0 0.0 408185328 1360 ?? S 16Dec23 0:34.06 /usr/sbin/distnoted")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ has mechanisms to print better to console, see the methods below
|
|||||||
import as
|
import as
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -24,23 +24,23 @@ fn color_fg(c ForegroundColor) string
|
|||||||
|
|
||||||
struct PrintArgs {
|
struct PrintArgs {
|
||||||
pub mut:
|
pub mut:
|
||||||
foreground ForegroundColor
|
foreground ForegroundColor
|
||||||
background BackgroundColor
|
background BackgroundColor
|
||||||
text string
|
text string
|
||||||
style Style
|
style Style
|
||||||
reset_before bool = true
|
reset_before bool = true
|
||||||
reset_after bool = true
|
reset_after bool = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cprint(args PrintArgs)
|
fn cprint(args PrintArgs)
|
||||||
// print with colors, reset...
|
// print with colors, reset...
|
||||||
// ```
|
// ```
|
||||||
// foreground ForegroundColor
|
// foreground ForegroundColor
|
||||||
// background BackgroundColor
|
// background BackgroundColor
|
||||||
// text string
|
// text string
|
||||||
// style Style
|
// style Style
|
||||||
// reset_before bool = true
|
// reset_before bool = true
|
||||||
// reset_after bool = true
|
// reset_after bool = true
|
||||||
// ```
|
// ```
|
||||||
|
|
||||||
fn cprintln(args_ PrintArgs)
|
fn cprintln(args_ PrintArgs)
|
||||||
@@ -95,11 +95,11 @@ Is used to ask feedback to users
|
|||||||
|
|
||||||
struct UIConsole {
|
struct UIConsole {
|
||||||
pub mut:
|
pub mut:
|
||||||
x_max int = 80
|
x_max int = 80
|
||||||
y_max int = 60
|
y_max int = 60
|
||||||
prev_lf bool
|
prev_lf bool
|
||||||
prev_title bool
|
prev_title bool
|
||||||
prev_item bool
|
prev_item bool
|
||||||
}
|
}
|
||||||
|
|
||||||
//DropDownArgs:
|
//DropDownArgs:
|
||||||
@@ -150,51 +150,51 @@ fn (mut c UIConsole) status() string
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
enum BackgroundColor {
|
enum BackgroundColor {
|
||||||
default_color = 49 // 'default' is a reserved keyword in V
|
default_color = 49 // 'default' is a reserved keyword in V
|
||||||
black = 40
|
black = 40
|
||||||
red = 41
|
red = 41
|
||||||
green = 42
|
green = 42
|
||||||
yellow = 43
|
yellow = 43
|
||||||
blue = 44
|
blue = 44
|
||||||
magenta = 45
|
magenta = 45
|
||||||
cyan = 46
|
cyan = 46
|
||||||
light_gray = 47
|
light_gray = 47
|
||||||
dark_gray = 100
|
dark_gray = 100
|
||||||
light_red = 101
|
light_red = 101
|
||||||
light_green = 102
|
light_green = 102
|
||||||
light_yellow = 103
|
light_yellow = 103
|
||||||
light_blue = 104
|
light_blue = 104
|
||||||
light_magenta = 105
|
light_magenta = 105
|
||||||
light_cyan = 106
|
light_cyan = 106
|
||||||
white = 107
|
white = 107
|
||||||
}
|
}
|
||||||
enum ForegroundColor {
|
enum ForegroundColor {
|
||||||
default_color = 39 // 'default' is a reserved keyword in V
|
default_color = 39 // 'default' is a reserved keyword in V
|
||||||
white = 97
|
white = 97
|
||||||
black = 30
|
black = 30
|
||||||
red = 31
|
red = 31
|
||||||
green = 32
|
green = 32
|
||||||
yellow = 33
|
yellow = 33
|
||||||
blue = 34
|
blue = 34
|
||||||
magenta = 35
|
magenta = 35
|
||||||
cyan = 36
|
cyan = 36
|
||||||
light_gray = 37
|
light_gray = 37
|
||||||
dark_gray = 90
|
dark_gray = 90
|
||||||
light_red = 91
|
light_red = 91
|
||||||
light_green = 92
|
light_green = 92
|
||||||
light_yellow = 93
|
light_yellow = 93
|
||||||
light_blue = 94
|
light_blue = 94
|
||||||
light_magenta = 95
|
light_magenta = 95
|
||||||
light_cyan = 96
|
light_cyan = 96
|
||||||
}
|
}
|
||||||
enum Style {
|
enum Style {
|
||||||
normal = 99
|
normal = 99
|
||||||
bold = 1
|
bold = 1
|
||||||
dim = 2
|
dim = 2
|
||||||
underline = 4
|
underline = 4
|
||||||
blink = 5
|
blink = 5
|
||||||
reverse = 7
|
reverse = 7
|
||||||
hidden = 8
|
hidden = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ this is how we want example scripts to be, see the first line
|
|||||||
```v
|
```v
|
||||||
#!/usr/bin/env -S v -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib...
|
import incubaid.herolib...
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -674,6 +674,7 @@
|
|||||||
|
|
||||||
<file_contents>
|
<file_contents>
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/ai_instructions.md
|
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/ai_instructions.md
|
||||||
|
|
||||||
```md
|
```md
|
||||||
# HeroDB Model Creation Instructions for AI
|
# HeroDB Model Creation Instructions for AI
|
||||||
|
|
||||||
@@ -701,14 +702,14 @@ Define your model struct with the following pattern:
|
|||||||
```v
|
```v
|
||||||
@[heap]
|
@[heap]
|
||||||
pub struct Calendar {
|
pub struct Calendar {
|
||||||
db.Base // Inherit from Base struct
|
db.Base // Inherit from Base struct
|
||||||
pub mut:
|
pub mut:
|
||||||
// Add your specific fields here
|
// Add your specific fields here
|
||||||
title string
|
title string
|
||||||
start_time i64
|
start_time i64
|
||||||
end_time i64
|
end_time i64
|
||||||
location string
|
location string
|
||||||
attendees []string
|
attendees []string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -718,7 +719,7 @@ Implement a method to return the model's type name:
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (self Calendar) type_name() string {
|
pub fn (self Calendar) type_name() string {
|
||||||
return 'calendar'
|
return 'calendar'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -728,11 +729,11 @@ Implement the `dump` method to serialize your struct's fields using the encoder:
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (self Calendar) dump(mut e &encoder.Encoder) ! {
|
pub fn (self Calendar) dump(mut e &encoder.Encoder) ! {
|
||||||
e.add_string(self.title)
|
e.add_string(self.title)
|
||||||
e.add_i64(self.start_time)
|
e.add_i64(self.start_time)
|
||||||
e.add_i64(self.end_time)
|
e.add_i64(self.end_time)
|
||||||
e.add_string(self.location)
|
e.add_string(self.location)
|
||||||
e.add_list_string(self.attendees)
|
e.add_list_string(self.attendees)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -742,11 +743,11 @@ Implement the `load` method to deserialize your struct's fields:
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
fn (mut self DBCalendar) load(mut o Calendar, mut e &encoder.Decoder) ! {
|
fn (mut self DBCalendar) load(mut o Calendar, mut e &encoder.Decoder) ! {
|
||||||
o.title = e.get_string()!
|
o.title = e.get_string()!
|
||||||
o.start_time = e.get_i64()!
|
o.start_time = e.get_i64()!
|
||||||
o.end_time = e.get_i64()!
|
o.end_time = e.get_i64()!
|
||||||
o.location = e.get_string()!
|
o.location = e.get_string()!
|
||||||
o.attendees = e.get_list_string()!
|
o.attendees = e.get_list_string()!
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -758,11 +759,11 @@ Define a struct for creating new instances of your model:
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct CalendarArg {
|
pub struct CalendarArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
title string @[required]
|
title string @[required]
|
||||||
start_time i64
|
start_time i64
|
||||||
end_time i64
|
end_time i64
|
||||||
location string
|
location string
|
||||||
attendees []string
|
attendees []string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -773,7 +774,7 @@ Create a database wrapper struct for your model:
|
|||||||
```v
|
```v
|
||||||
pub struct DBCalendar {
|
pub struct DBCalendar {
|
||||||
pub mut:
|
pub mut:
|
||||||
db &db.DB @[skip; str: skip]
|
db &db.DB @[skip; str: skip]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -784,8 +785,8 @@ Add your model to the ModelsFactory struct in `factory.v`:
|
|||||||
```v
|
```v
|
||||||
pub struct ModelsFactory {
|
pub struct ModelsFactory {
|
||||||
pub mut:
|
pub mut:
|
||||||
comments DBCalendar
|
comments DBCalendar
|
||||||
// ... other models
|
// ... other models
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -793,13 +794,13 @@ And initialize it in the `new()` function:
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn new() !ModelsFactory {
|
pub fn new() !ModelsFactory {
|
||||||
mut mydb := db.new()!
|
mut mydb := db.new()!
|
||||||
return ModelsFactory{
|
return ModelsFactory{
|
||||||
comments: DBCalendar{
|
comments: DBCalendar{
|
||||||
db: &mydb
|
db: &mydb
|
||||||
}
|
}
|
||||||
// ... initialize other models
|
// ... initialize other models
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -808,6 +809,7 @@ pub fn new() !ModelsFactory {
|
|||||||
Use these methods for serialization/deserialization:
|
Use these methods for serialization/deserialization:
|
||||||
|
|
||||||
### Encoder (Serialization)
|
### Encoder (Serialization)
|
||||||
|
|
||||||
- `e.add_bool(val bool)`
|
- `e.add_bool(val bool)`
|
||||||
- `e.add_u8(val u8)`
|
- `e.add_u8(val u8)`
|
||||||
- `e.add_u16(val u16)`
|
- `e.add_u16(val u16)`
|
||||||
@@ -834,6 +836,7 @@ Use these methods for serialization/deserialization:
|
|||||||
- `e.add_list_string(val []string)`
|
- `e.add_list_string(val []string)`
|
||||||
|
|
||||||
### Decoder (Deserialization)
|
### Decoder (Deserialization)
|
||||||
|
|
||||||
- `e.get_bool()!`
|
- `e.get_bool()!`
|
||||||
- `e.get_u8()!`
|
- `e.get_u8()!`
|
||||||
- `e.get_u16()!`
|
- `e.get_u16()!`
|
||||||
@@ -862,55 +865,61 @@ Use these methods for serialization/deserialization:
|
|||||||
## CRUD Methods Implementation
|
## CRUD Methods Implementation
|
||||||
|
|
||||||
### Create New Instance
|
### Create New Instance
|
||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (mut self DBCalendar) new(args CalendarArg) !Calendar {
|
pub fn (mut self DBCalendar) new(args CalendarArg) !Calendar {
|
||||||
mut o := Calendar{
|
mut o := Calendar{
|
||||||
title: args.title
|
title: args.title
|
||||||
start_time: args.start_time
|
start_time: args.start_time
|
||||||
end_time: args.end_time
|
end_time: args.end_time
|
||||||
location: args.location
|
location: args.location
|
||||||
attendees: args.attendees
|
attendees: args.attendees
|
||||||
updated_at: ourtime.now().unix()
|
updated_at: ourtime.now().unix()
|
||||||
}
|
}
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Save to Database
|
### Save to Database
|
||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (mut self DBCalendar) set(o Calendar) !u32 {
|
pub fn (mut self DBCalendar) set(o Calendar) !u32 {
|
||||||
return self.db.set[Calendar](o)!
|
return self.db.set[Calendar](o)!
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Retrieve from Database
|
### Retrieve from Database
|
||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (mut self DBCalendar) get(id u32) !Calendar {
|
pub fn (mut self DBCalendar) get(id u32) !Calendar {
|
||||||
mut o, data := self.db.get_data[Calendar](id)!
|
mut o, data := self.db.get_data[Calendar](id)!
|
||||||
mut e_decoder := encoder.decoder_new(data)
|
mut e_decoder := encoder.decoder_new(data)
|
||||||
self.load(mut o, mut e_decoder)!
|
self.load(mut o, mut e_decoder)!
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Delete from Database
|
### Delete from Database
|
||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (mut self DBCalendar) delete(id u32) ! {
|
pub fn (mut self DBCalendar) delete(id u32) ! {
|
||||||
self.db.delete[Calendar](id)!
|
self.db.delete[Calendar](id)!
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Check Existence
|
### Check Existence
|
||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (mut self DBCalendar) exist(id u32) !bool {
|
pub fn (mut self DBCalendar) exist(id u32) !bool {
|
||||||
return self.db.exists[Calendar](id)!
|
return self.db.exists[Calendar](id)!
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### List All Objects
|
### List All Objects
|
||||||
|
|
||||||
```v
|
```v
|
||||||
pub fn (mut self DBCalendar) list() ![]Calendar {
|
pub fn (mut self DBCalendar) list() ![]Calendar {
|
||||||
return self.db.list[Calendar]()!.map(self.get(it)!)
|
return self.db.list[Calendar]()!.map(self.get(it)!)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -921,18 +930,18 @@ Create a `.vsh` script in `examples/hero/heromodels/` to demonstrate usage:
|
|||||||
```v
|
```v
|
||||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.redisclient
|
import incubaid.herolib.core.redisclient
|
||||||
import freeflowuniverse.herolib.hero.heromodels
|
import incubaid.herolib.hero.heromodels
|
||||||
|
|
||||||
mut mydb := heromodels.new()!
|
mut mydb := heromodels.new()!
|
||||||
|
|
||||||
// Create a new object
|
// Create a new object
|
||||||
mut o := mydb.calendar.new(
|
mut o := mydb.calendar.new(
|
||||||
title: 'Meeting'
|
title: 'Meeting'
|
||||||
start_time: 1672531200
|
start_time: 1672531200
|
||||||
end_time: 1672534800
|
end_time: 1672534800
|
||||||
location: 'Conference Room'
|
location: 'Conference Room'
|
||||||
attendees: ['john@example.com', 'jane@example.com']
|
attendees: ['john@example.com', 'jane@example.com']
|
||||||
)!
|
)!
|
||||||
|
|
||||||
// Save to database
|
// Save to database
|
||||||
@@ -971,160 +980,163 @@ println('All objects: ${objects}')
|
|||||||
8. Implement CRUD methods
|
8. Implement CRUD methods
|
||||||
9. Create example usage script
|
9. Create example usage script
|
||||||
10. Test the implementation with the example script
|
10. Test the implementation with the example script
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/core_methods.v
|
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/core_methods.v
|
||||||
```v
|
```v
|
||||||
module db
|
module db
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
import freeflowuniverse.herolib.data.encoder
|
import incubaid.herolib.data.encoder
|
||||||
|
|
||||||
pub fn (mut self DB) set[T](obj_ T) !u32 {
|
pub fn (mut self DB) set[T](obj_ T) !u32 {
|
||||||
// Get the next ID
|
// Get the next ID
|
||||||
mut obj := obj_
|
mut obj := obj_
|
||||||
if obj.id == 0 {
|
if obj.id == 0 {
|
||||||
obj.id = self.new_id()!
|
obj.id = self.new_id()!
|
||||||
}
|
}
|
||||||
mut t := ourtime.now().unix()
|
mut t := ourtime.now().unix()
|
||||||
if obj.created_at == 0 {
|
if obj.created_at == 0 {
|
||||||
obj.created_at = t
|
obj.created_at = t
|
||||||
}
|
}
|
||||||
obj.updated_at = t
|
obj.updated_at = t
|
||||||
|
|
||||||
// id u32
|
// id u32
|
||||||
// name string
|
// name string
|
||||||
// description string
|
// description string
|
||||||
// created_at i64
|
// created_at i64
|
||||||
// updated_at i64
|
// updated_at i64
|
||||||
// securitypolicy u32
|
// securitypolicy u32
|
||||||
// tags u32 // when we set/get we always do as []string but this can then be sorted and md5ed this gies the unique id of tags
|
// tags u32 // when we set/get we always do as []string but this can then be sorted and md5ed this gies the unique id of tags
|
||||||
// comments []u32
|
// comments []u32
|
||||||
mut e := encoder.new()
|
mut e := encoder.new()
|
||||||
e.add_u8(1)
|
e.add_u8(1)
|
||||||
e.add_u32(obj.id)
|
e.add_u32(obj.id)
|
||||||
e.add_string(obj.name)
|
e.add_string(obj.name)
|
||||||
e.add_string(obj.description)
|
e.add_string(obj.description)
|
||||||
e.add_i64(obj.created_at)
|
e.add_i64(obj.created_at)
|
||||||
e.add_i64(obj.updated_at)
|
e.add_i64(obj.updated_at)
|
||||||
e.add_u32(obj.securitypolicy)
|
e.add_u32(obj.securitypolicy)
|
||||||
e.add_u32(obj.tags)
|
e.add_u32(obj.tags)
|
||||||
e.add_u16(u16(obj.comments.len))
|
e.add_u16(u16(obj.comments.len))
|
||||||
for comment in obj.comments {
|
for comment in obj.comments {
|
||||||
e.add_u32(comment)
|
e.add_u32(comment)
|
||||||
}
|
}
|
||||||
// println('set: before dump, e.data.len: ${e.data.len}')
|
// println('set: before dump, e.data.len: ${e.data.len}')
|
||||||
obj.dump(mut e)!
|
obj.dump(mut e)!
|
||||||
// println('set: after dump, e.data.len: ${e.data.len}')
|
// println('set: after dump, e.data.len: ${e.data.len}')
|
||||||
self.redis.hset(self.db_name[T](), obj.id.str(), e.data.bytestr())!
|
self.redis.hset(self.db_name[T](), obj.id.str(), e.data.bytestr())!
|
||||||
return obj.id
|
return obj.id
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the data, cannot return the object as we do not know the type
|
// return the data, cannot return the object as we do not know the type
|
||||||
pub fn (mut self DB) get_data[T](id u32) !(T, []u8) {
|
pub fn (mut self DB) get_data[T](id u32) !(T, []u8) {
|
||||||
data := self.redis.hget(self.db_name[T](), id.str())!
|
data := self.redis.hget(self.db_name[T](), id.str())!
|
||||||
|
|
||||||
if data.len == 0 {
|
if data.len == 0 {
|
||||||
return error('herodb:${self.db_name[T]()} not found for ${id}')
|
return error('herodb:${self.db_name[T]()} not found for ${id}')
|
||||||
}
|
}
|
||||||
|
|
||||||
// println('get_data: data.len: ${data.len}')
|
// println('get_data: data.len: ${data.len}')
|
||||||
mut e := encoder.decoder_new(data.bytes())
|
mut e := encoder.decoder_new(data.bytes())
|
||||||
version := e.get_u8()!
|
version := e.get_u8()!
|
||||||
if version != 1 {
|
if version != 1 {
|
||||||
panic('wrong version in base load')
|
panic('wrong version in base load')
|
||||||
}
|
}
|
||||||
mut base := T{}
|
mut base := T{}
|
||||||
base.id = e.get_u32()!
|
base.id = e.get_u32()!
|
||||||
base.name = e.get_string()!
|
base.name = e.get_string()!
|
||||||
base.description = e.get_string()!
|
base.description = e.get_string()!
|
||||||
base.created_at = e.get_i64()!
|
base.created_at = e.get_i64()!
|
||||||
base.updated_at = e.get_i64()!
|
base.updated_at = e.get_i64()!
|
||||||
base.securitypolicy = e.get_u32()!
|
base.securitypolicy = e.get_u32()!
|
||||||
base.tags = e.get_u32()!
|
base.tags = e.get_u32()!
|
||||||
for _ in 0 .. e.get_u16()! {
|
for _ in 0 .. e.get_u16()! {
|
||||||
base.comments << e.get_u32()!
|
base.comments << e.get_u32()!
|
||||||
}
|
}
|
||||||
return base, e.data
|
return base, e.data
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DB) exists[T](id u32) !bool {
|
pub fn (mut self DB) exists[T](id u32) !bool {
|
||||||
return self.redis.hexists(self.db_name[T](), id.str())!
|
return self.redis.hexists(self.db_name[T](), id.str())!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DB) delete[T](id u32) ! {
|
pub fn (mut self DB) delete[T](id u32) ! {
|
||||||
self.redis.hdel(self.db_name[T](), id.str())!
|
self.redis.hdel(self.db_name[T](), id.str())!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DB) list[T]() ![]u32 {
|
pub fn (mut self DB) list[T]() ![]u32 {
|
||||||
ids := self.redis.hkeys(self.db_name[T]())!
|
ids := self.redis.hkeys(self.db_name[T]())!
|
||||||
return ids.map(it.u32())
|
return ids.map(it.u32())
|
||||||
}
|
}
|
||||||
|
|
||||||
// make it easy to get a base object
|
// make it easy to get a base object
|
||||||
pub fn (mut self DB) new_from_base[T](args BaseArgs) !Base {
|
pub fn (mut self DB) new_from_base[T](args BaseArgs) !Base {
|
||||||
return T{
|
return T{
|
||||||
Base: new_base(args)!
|
Base: new_base(args)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DB) db_name[T]() string {
|
fn (mut self DB) db_name[T]() string {
|
||||||
// get the name of the type T
|
// get the name of the type T
|
||||||
mut name := T.name.to_lower_ascii().split('.').last()
|
mut name := T.name.to_lower_ascii().split('.').last()
|
||||||
// println("db_name rediskey: '${name}'")
|
// println("db_name rediskey: '${name}'")
|
||||||
return 'db:${name}'
|
return 'db:${name}'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DB) new_id() !u32 {
|
pub fn (mut self DB) new_id() !u32 {
|
||||||
return u32(self.redis.incr('db:id')!)
|
return u32(self.redis.incr('db:id')!)
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/core_models.v
|
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/core_models.v
|
||||||
|
|
||||||
```v
|
```v
|
||||||
module db
|
module db
|
||||||
|
|
||||||
import crypto.md5
|
import crypto.md5
|
||||||
import freeflowuniverse.herolib.core.redisclient
|
import incubaid.herolib.core.redisclient
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
|
|
||||||
// Group represents a collection of users with roles and permissions
|
// Group represents a collection of users with roles and permissions
|
||||||
@[heap]
|
@[heap]
|
||||||
pub struct Base {
|
pub struct Base {
|
||||||
pub mut:
|
pub mut:
|
||||||
id u32
|
id u32
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
created_at i64
|
created_at i64
|
||||||
updated_at i64
|
updated_at i64
|
||||||
securitypolicy u32
|
securitypolicy u32
|
||||||
tags u32 // when we set/get we always do as []string but this can then be sorted and md5ed this gies the unique id of tags
|
tags u32 // when we set/get we always do as []string but this can then be sorted and md5ed this gies the unique id of tags
|
||||||
comments []u32
|
comments []u32
|
||||||
}
|
}
|
||||||
|
|
||||||
@[heap]
|
@[heap]
|
||||||
pub struct SecurityPolicy {
|
pub struct SecurityPolicy {
|
||||||
pub mut:
|
pub mut:
|
||||||
id u32
|
id u32
|
||||||
read []u32 // links to users & groups
|
read []u32 // links to users & groups
|
||||||
write []u32 // links to users & groups
|
write []u32 // links to users & groups
|
||||||
delete []u32 // links to users & groups
|
delete []u32 // links to users & groups
|
||||||
public bool
|
public bool
|
||||||
md5 string // this sorts read, write and delete u32 + hash, then do md5 hash, this allows to go from a random read/write/delete/public config to a hash
|
md5 string // this sorts read, write and delete u32 + hash, then do md5 hash, this allows to go from a random read/write/delete/public config to a hash
|
||||||
}
|
}
|
||||||
|
|
||||||
@[heap]
|
@[heap]
|
||||||
pub struct Tags {
|
pub struct Tags {
|
||||||
pub mut:
|
pub mut:
|
||||||
id u32
|
id u32
|
||||||
names []string // unique per id
|
names []string // unique per id
|
||||||
md5 string // of sorted names, to make easy to find unique id, each name lowercased and made ascii
|
md5 string // of sorted names, to make easy to find unique id, each name lowercased and made ascii
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/helpers_comments.v
|
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/helpers_comments.v
|
||||||
|
|
||||||
```v
|
```v
|
||||||
module db
|
module db
|
||||||
|
|
||||||
@@ -1134,298 +1146,301 @@ import crypto.md5
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct CommentArg {
|
pub struct CommentArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
comment string
|
comment string
|
||||||
parent u32
|
parent u32
|
||||||
author u32
|
author u32
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DB) comments_get(args []CommentArg) ![]u32 {
|
pub fn (mut self DB) comments_get(args []CommentArg) ![]u32 {
|
||||||
return args.map(self.comment_get(it.comment)!)
|
return args.map(self.comment_get(it.comment)!)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DB) comment_get(comment string) !u32 {
|
pub fn (mut self DB) comment_get(comment string) !u32 {
|
||||||
comment_fixed := comment.to_lower_ascii().trim_space()
|
comment_fixed := comment.to_lower_ascii().trim_space()
|
||||||
return if comment_fixed.len > 0 {
|
return if comment_fixed.len > 0 {
|
||||||
hash := md5.hexhash(comment_fixed)
|
hash := md5.hexhash(comment_fixed)
|
||||||
comment_found := self.redis.hget('db:comments', hash)!
|
comment_found := self.redis.hget('db:comments', hash)!
|
||||||
if comment_found == '' {
|
if comment_found == '' {
|
||||||
id := self.new_id()!
|
id := self.new_id()!
|
||||||
self.redis.hset('db:comments', hash, id.str())!
|
self.redis.hset('db:comments', hash, id.str())!
|
||||||
self.redis.hset('db:comments', id.str(), comment_fixed)!
|
self.redis.hset('db:comments', id.str(), comment_fixed)!
|
||||||
id
|
id
|
||||||
} else {
|
} else {
|
||||||
comment_found.u32()
|
comment_found.u32()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/helpers_tags.v
|
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/db/helpers_tags.v
|
||||||
|
|
||||||
```v
|
```v
|
||||||
module db
|
module db
|
||||||
|
|
||||||
import crypto.md5
|
import crypto.md5
|
||||||
|
|
||||||
pub fn (mut self DB) tags_get(tags []string) !u32 {
|
pub fn (mut self DB) tags_get(tags []string) !u32 {
|
||||||
return if tags.len > 0 {
|
return if tags.len > 0 {
|
||||||
mut tags_fixed := tags.map(it.to_lower_ascii().trim_space()).filter(it != '')
|
mut tags_fixed := tags.map(it.to_lower_ascii().trim_space()).filter(it != '')
|
||||||
tags_fixed.sort_ignore_case()
|
tags_fixed.sort_ignore_case()
|
||||||
hash := md5.hexhash(tags_fixed.join(','))
|
hash := md5.hexhash(tags_fixed.join(','))
|
||||||
tags_found := self.redis.hget('db:tags', hash)!
|
tags_found := self.redis.hget('db:tags', hash)!
|
||||||
return if tags_found == '' {
|
return if tags_found == '' {
|
||||||
println('tags_get: new tags: ${tags_fixed.join(",")}')
|
println('tags_get: new tags: ${tags_fixed.join(",")}')
|
||||||
id := self.new_id()!
|
id := self.new_id()!
|
||||||
self.redis.hset('db:tags', hash, id.str())!
|
self.redis.hset('db:tags', hash, id.str())!
|
||||||
self.redis.hset('db:tags', id.str(), tags_fixed.join(','))!
|
self.redis.hset('db:tags', id.str(), tags_fixed.join(','))!
|
||||||
id
|
id
|
||||||
} else {
|
} else {
|
||||||
tags_found.u32()
|
tags_found.u32()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/heromodels/calendar_event.v
|
File: /Users/despiegk/code/github/incubaid/herolib/lib/hero/heromodels/calendar_event.v
|
||||||
|
|
||||||
```v
|
```v
|
||||||
|
|
||||||
module heromodels
|
module heromodels
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.encoder
|
import incubaid.herolib.data.encoder
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
import freeflowuniverse.herolib.hero.db
|
import incubaid.herolib.hero.db
|
||||||
|
|
||||||
// CalendarEvent represents a single event in a calendar
|
// CalendarEvent represents a single event in a calendar
|
||||||
@[heap]
|
@[heap]
|
||||||
pub struct CalendarEvent {
|
pub struct CalendarEvent {
|
||||||
db.Base
|
db.Base
|
||||||
pub mut:
|
pub mut:
|
||||||
title string
|
title string
|
||||||
start_time i64 // Unix timestamp
|
start_time i64 // Unix timestamp
|
||||||
end_time i64 // Unix timestamp
|
end_time i64 // Unix timestamp
|
||||||
location string
|
location string
|
||||||
attendees []u32 // IDs of user groups
|
attendees []u32 // IDs of user groups
|
||||||
fs_items []u32 // IDs of linked files or dirs
|
fs_items []u32 // IDs of linked files or dirs
|
||||||
calendar_id u32 // Associated calendar
|
calendar_id u32 // Associated calendar
|
||||||
status EventStatus
|
status EventStatus
|
||||||
is_all_day bool
|
is_all_day bool
|
||||||
is_recurring bool
|
is_recurring bool
|
||||||
recurrence []RecurrenceRule // normally empty
|
recurrence []RecurrenceRule // normally empty
|
||||||
reminder_mins []int // Minutes before event for reminders
|
reminder_mins []int // Minutes before event for reminders
|
||||||
color string // Hex color code
|
color string // Hex color code
|
||||||
timezone string
|
timezone string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Attendee {
|
pub struct Attendee {
|
||||||
pub mut:
|
pub mut:
|
||||||
user_id u32
|
user_id u32
|
||||||
status AttendanceStatus
|
status AttendanceStatus
|
||||||
role AttendeeRole
|
role AttendeeRole
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum AttendanceStatus {
|
pub enum AttendanceStatus {
|
||||||
no_response
|
no_response
|
||||||
accepted
|
accepted
|
||||||
declined
|
declined
|
||||||
tentative
|
tentative
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum AttendeeRole {
|
pub enum AttendeeRole {
|
||||||
required
|
required
|
||||||
optional
|
optional
|
||||||
organizer
|
organizer
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum EventStatus {
|
pub enum EventStatus {
|
||||||
draft
|
draft
|
||||||
published
|
published
|
||||||
cancelled
|
cancelled
|
||||||
completed
|
completed
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RecurrenceRule {
|
pub struct RecurrenceRule {
|
||||||
pub mut:
|
pub mut:
|
||||||
frequency RecurrenceFreq
|
frequency RecurrenceFreq
|
||||||
interval int // Every N frequencies
|
interval int // Every N frequencies
|
||||||
until i64 // End date (Unix timestamp)
|
until i64 // End date (Unix timestamp)
|
||||||
count int // Number of occurrences
|
count int // Number of occurrences
|
||||||
by_weekday []int // Days of week (0=Sunday)
|
by_weekday []int // Days of week (0=Sunday)
|
||||||
by_monthday []int // Days of month
|
by_monthday []int // Days of month
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum RecurrenceFreq {
|
pub enum RecurrenceFreq {
|
||||||
none
|
none
|
||||||
daily
|
daily
|
||||||
weekly
|
weekly
|
||||||
monthly
|
monthly
|
||||||
yearly
|
yearly
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DBCalendarEvent {
|
pub struct DBCalendarEvent {
|
||||||
pub mut:
|
pub mut:
|
||||||
db &db.DB @[skip; str: skip]
|
db &db.DB @[skip; str: skip]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self CalendarEvent) type_name() string {
|
pub fn (self CalendarEvent) type_name() string {
|
||||||
return 'calendar_event'
|
return 'calendar_event'
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (self CalendarEvent) dump(mut e &encoder.Encoder) ! {
|
pub fn (self CalendarEvent) dump(mut e &encoder.Encoder) ! {
|
||||||
e.add_string(self.title)
|
e.add_string(self.title)
|
||||||
e.add_i64(self.start_time)
|
e.add_i64(self.start_time)
|
||||||
e.add_i64(self.end_time)
|
e.add_i64(self.end_time)
|
||||||
e.add_string(self.location)
|
e.add_string(self.location)
|
||||||
e.add_list_u32(self.attendees)
|
e.add_list_u32(self.attendees)
|
||||||
e.add_list_u32(self.fs_items)
|
e.add_list_u32(self.fs_items)
|
||||||
e.add_u32(self.calendar_id)
|
e.add_u32(self.calendar_id)
|
||||||
e.add_u8(u8(self.status))
|
e.add_u8(u8(self.status))
|
||||||
e.add_bool(self.is_all_day)
|
e.add_bool(self.is_all_day)
|
||||||
e.add_bool(self.is_recurring)
|
e.add_bool(self.is_recurring)
|
||||||
|
|
||||||
// Encode recurrence array
|
// Encode recurrence array
|
||||||
e.add_u16(u16(self.recurrence.len))
|
e.add_u16(u16(self.recurrence.len))
|
||||||
for rule in self.recurrence {
|
for rule in self.recurrence {
|
||||||
e.add_u8(u8(rule.frequency))
|
e.add_u8(u8(rule.frequency))
|
||||||
e.add_int(rule.interval)
|
e.add_int(rule.interval)
|
||||||
e.add_i64(rule.until)
|
e.add_i64(rule.until)
|
||||||
e.add_int(rule.count)
|
e.add_int(rule.count)
|
||||||
e.add_list_int(rule.by_weekday)
|
e.add_list_int(rule.by_weekday)
|
||||||
e.add_list_int(rule.by_monthday)
|
e.add_list_int(rule.by_monthday)
|
||||||
}
|
}
|
||||||
|
|
||||||
e.add_list_int(self.reminder_mins)
|
e.add_list_int(self.reminder_mins)
|
||||||
e.add_string(self.color)
|
e.add_string(self.color)
|
||||||
e.add_string(self.timezone)
|
e.add_string(self.timezone)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut self DBCalendarEvent) load(mut o CalendarEvent, mut e &encoder.Decoder) ! {
|
fn (mut self DBCalendarEvent) load(mut o CalendarEvent, mut e &encoder.Decoder) ! {
|
||||||
o.title = e.get_string()!
|
o.title = e.get_string()!
|
||||||
o.start_time = e.get_i64()!
|
o.start_time = e.get_i64()!
|
||||||
o.end_time = e.get_i64()!
|
o.end_time = e.get_i64()!
|
||||||
o.location = e.get_string()!
|
o.location = e.get_string()!
|
||||||
o.attendees = e.get_list_u32()!
|
o.attendees = e.get_list_u32()!
|
||||||
o.fs_items = e.get_list_u32()!
|
o.fs_items = e.get_list_u32()!
|
||||||
o.calendar_id = e.get_u32()!
|
o.calendar_id = e.get_u32()!
|
||||||
o.status = unsafe { EventStatus(e.get_u8()!) } //TODO: is there no better way?
|
o.status = unsafe { EventStatus(e.get_u8()!) } //TODO: is there no better way?
|
||||||
o.is_all_day = e.get_bool()!
|
o.is_all_day = e.get_bool()!
|
||||||
o.is_recurring = e.get_bool()!
|
o.is_recurring = e.get_bool()!
|
||||||
|
|
||||||
// Decode recurrence array
|
// Decode recurrence array
|
||||||
recurrence_len := e.get_u16()!
|
recurrence_len := e.get_u16()!
|
||||||
mut recurrence := []RecurrenceRule{}
|
mut recurrence := []RecurrenceRule{}
|
||||||
for _ in 0 .. recurrence_len {
|
for _ in 0 .. recurrence_len {
|
||||||
frequency := unsafe { RecurrenceFreq(e.get_u8()!) }
|
frequency := unsafe { RecurrenceFreq(e.get_u8()!) }
|
||||||
interval := e.get_int()!
|
interval := e.get_int()!
|
||||||
until := e.get_i64()!
|
until := e.get_i64()!
|
||||||
count := e.get_int()!
|
count := e.get_int()!
|
||||||
by_weekday := e.get_list_int()!
|
by_weekday := e.get_list_int()!
|
||||||
by_monthday := e.get_list_int()!
|
by_monthday := e.get_list_int()!
|
||||||
|
|
||||||
recurrence << RecurrenceRule{
|
recurrence << RecurrenceRule{
|
||||||
frequency: frequency
|
frequency: frequency
|
||||||
interval: interval
|
interval: interval
|
||||||
until: until
|
until: until
|
||||||
count: count
|
count: count
|
||||||
by_weekday: by_weekday
|
by_weekday: by_weekday
|
||||||
by_monthday: by_monthday
|
by_monthday: by_monthday
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.recurrence = recurrence
|
o.recurrence = recurrence
|
||||||
|
|
||||||
o.reminder_mins = e.get_list_int()!
|
o.reminder_mins = e.get_list_int()!
|
||||||
o.color = e.get_string()!
|
o.color = e.get_string()!
|
||||||
o.timezone = e.get_string()!
|
o.timezone = e.get_string()!
|
||||||
}
|
}
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct CalendarEventArg {
|
pub struct CalendarEventArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
title string
|
title string
|
||||||
start_time string // use ourtime module to go from string to epoch
|
start_time string // use ourtime module to go from string to epoch
|
||||||
end_time string // use ourtime module to go from string to epoch
|
end_time string // use ourtime module to go from string to epoch
|
||||||
location string
|
location string
|
||||||
attendees []u32 // IDs of user groups
|
attendees []u32 // IDs of user groups
|
||||||
fs_items []u32 // IDs of linked files or dirs
|
fs_items []u32 // IDs of linked files or dirs
|
||||||
calendar_id u32 // Associated calendar
|
calendar_id u32 // Associated calendar
|
||||||
status EventStatus
|
status EventStatus
|
||||||
is_all_day bool
|
is_all_day bool
|
||||||
is_recurring bool
|
is_recurring bool
|
||||||
recurrence []RecurrenceRule
|
recurrence []RecurrenceRule
|
||||||
reminder_mins []int // Minutes before event for reminders
|
reminder_mins []int // Minutes before event for reminders
|
||||||
color string // Hex color code
|
color string // Hex color code
|
||||||
timezone string
|
timezone string
|
||||||
securitypolicy u32
|
securitypolicy u32
|
||||||
tags []string
|
tags []string
|
||||||
comments []db.CommentArg
|
comments []db.CommentArg
|
||||||
}
|
}
|
||||||
|
|
||||||
// get new calendar event, not from the DB
|
// get new calendar event, not from the DB
|
||||||
pub fn (mut self DBCalendarEvent) new(args CalendarEventArg) !CalendarEvent {
|
pub fn (mut self DBCalendarEvent) new(args CalendarEventArg) !CalendarEvent {
|
||||||
mut o := CalendarEvent{
|
mut o := CalendarEvent{
|
||||||
title: args.title
|
title: args.title
|
||||||
location: args.location
|
location: args.location
|
||||||
attendees: args.attendees
|
attendees: args.attendees
|
||||||
fs_items: args.fs_items
|
fs_items: args.fs_items
|
||||||
calendar_id: args.calendar_id
|
calendar_id: args.calendar_id
|
||||||
status: args.status
|
status: args.status
|
||||||
is_all_day: args.is_all_day
|
is_all_day: args.is_all_day
|
||||||
is_recurring: args.is_recurring
|
is_recurring: args.is_recurring
|
||||||
recurrence: args.recurrence
|
recurrence: args.recurrence
|
||||||
reminder_mins: args.reminder_mins
|
reminder_mins: args.reminder_mins
|
||||||
color: args.color
|
color: args.color
|
||||||
timezone: args.timezone
|
timezone: args.timezone
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set base fields
|
// Set base fields
|
||||||
o.name = args.name
|
o.name = args.name
|
||||||
o.description = args.description
|
o.description = args.description
|
||||||
o.securitypolicy = args.securitypolicy
|
o.securitypolicy = args.securitypolicy
|
||||||
o.tags = self.db.tags_get(args.tags)!
|
o.tags = self.db.tags_get(args.tags)!
|
||||||
o.comments = self.db.comments_get(args.comments)!
|
o.comments = self.db.comments_get(args.comments)!
|
||||||
o.updated_at = ourtime.now().unix()
|
o.updated_at = ourtime.now().unix()
|
||||||
|
|
||||||
// Convert string times to Unix timestamps
|
// Convert string times to Unix timestamps
|
||||||
mut start_time_obj := ourtime.new(args.start_time)!
|
mut start_time_obj := ourtime.new(args.start_time)!
|
||||||
o.start_time = start_time_obj.unix()
|
o.start_time = start_time_obj.unix()
|
||||||
|
|
||||||
mut end_time_obj := ourtime.new(args.end_time)!
|
mut end_time_obj := ourtime.new(args.end_time)!
|
||||||
o.end_time = end_time_obj.unix()
|
o.end_time = end_time_obj.unix()
|
||||||
|
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DBCalendarEvent) set(o CalendarEvent) !u32 {
|
pub fn (mut self DBCalendarEvent) set(o CalendarEvent) !u32 {
|
||||||
// Use db set function which now returns the ID
|
// Use db set function which now returns the ID
|
||||||
return self.db.set[CalendarEvent](o)!
|
return self.db.set[CalendarEvent](o)!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DBCalendarEvent) delete(id u32) ! {
|
pub fn (mut self DBCalendarEvent) delete(id u32) ! {
|
||||||
self.db.delete[CalendarEvent](id)!
|
self.db.delete[CalendarEvent](id)!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DBCalendarEvent) exist(id u32) !bool {
|
pub fn (mut self DBCalendarEvent) exist(id u32) !bool {
|
||||||
return self.db.exists[CalendarEvent](id)!
|
return self.db.exists[CalendarEvent](id)!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DBCalendarEvent) get(id u32) !CalendarEvent {
|
pub fn (mut self DBCalendarEvent) get(id u32) !CalendarEvent {
|
||||||
mut o, data := self.db.get_data[CalendarEvent](id)!
|
mut o, data := self.db.get_data[CalendarEvent](id)!
|
||||||
mut e_decoder := encoder.decoder_new(data)
|
mut e_decoder := encoder.decoder_new(data)
|
||||||
self.load(mut o, mut e_decoder)!
|
self.load(mut o, mut e_decoder)!
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut self DBCalendarEvent) list() ![]CalendarEvent {
|
pub fn (mut self DBCalendarEvent) list() ![]CalendarEvent {
|
||||||
return self.db.list[CalendarEvent]()!.map(self.get(it)!)
|
return self.db.list[CalendarEvent]()!.map(self.get(it)!)
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</file_contents>
|
</file_contents>
|
||||||
<user_instructions>
|
<user_instructions>
|
||||||
make the crud and example for all files in lib/hero/herofs
|
make the crud and example for all files in lib/hero/herofs
|
||||||
@@ -1436,5 +1451,4 @@ check the implementation
|
|||||||
|
|
||||||
do the implementation
|
do the implementation
|
||||||
|
|
||||||
|
|
||||||
</user_instructions>
|
</user_instructions>
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ the template is as follows
|
|||||||
## factory
|
## factory
|
||||||
|
|
||||||
is there factory, which one and quick example how to call, don’t say in which file not relevant
|
is there factory, which one and quick example how to call, don’t say in which file not relevant
|
||||||
show how to import the module is as follows: import freeflowuniverse.herolib.
|
show how to import the module is as follows: import incubaid.herolib.
|
||||||
and then starting from lib e.g. lib/clients/mycelium would result in import freeflowuniverse.herolib. clients.mycelium
|
and then starting from lib e.g. lib/clients/mycelium would result in import incubaid.herolib. clients.mycelium
|
||||||
|
|
||||||
## overview
|
## overview
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,11 @@ start of output file is:
|
|||||||
## factory
|
## factory
|
||||||
|
|
||||||
is there factory, which one and quick example how to call, don’t say in which file not relevant
|
is there factory, which one and quick example how to call, don’t say in which file not relevant
|
||||||
show how to import the module is as follows: import freeflowuniverse.herolib.
|
show how to import the module is as follows: import incubaid.herolib.
|
||||||
and then starting from lib e.g. lib/clients/mycelium would result in import freeflowuniverse.herolib. clients.mycelium
|
and then starting from lib e.g. lib/clients/mycelium would result in import incubaid.herolib. clients.mycelium
|
||||||
|
|
||||||
## structs and methods
|
## structs and methods
|
||||||
|
|
||||||
quick overview as list with identations, of the structs and its methods
|
quick overview as list with identations, of the structs and its methods
|
||||||
|
|
||||||
|
|
||||||
ONLY OUTPUT THE MARKDOWN FILE, NOTHING ELSE
|
ONLY OUTPUT THE MARKDOWN FILE, NOTHING ELSE
|
||||||
|
|
||||||
|
|||||||
@@ -468,6 +468,7 @@
|
|||||||
|
|
||||||
<file_contents>
|
<file_contents>
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_curdir_example.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_curdir_example.md
|
||||||
|
|
||||||
```md
|
```md
|
||||||
# Getting the Current Script's Path in Herolib/V Shell
|
# Getting the Current Script's Path in Herolib/V Shell
|
||||||
|
|
||||||
@@ -493,42 +494,43 @@ the following is a good pragmatic way to remember clients, installers as a globa
|
|||||||
|
|
||||||
module docsite
|
module docsite
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.texttools
|
import incubaid.herolib.core.texttools
|
||||||
|
|
||||||
__global (
|
__global (
|
||||||
siteconfigs map[string]&SiteConfig
|
siteconfigs map[string]&SiteConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct FactoryArgs {
|
pub struct FactoryArgs {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string = "default"
|
name string = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(args FactoryArgs) !&SiteConfig {
|
pub fn new(args FactoryArgs) !&SiteConfig {
|
||||||
name := texttools.name_fix(args.name)
|
name := texttools.name_fix(args.name)
|
||||||
siteconfigs[name] = &SiteConfig{
|
siteconfigs[name] = &SiteConfig{
|
||||||
name: name
|
name: name
|
||||||
}
|
}
|
||||||
return get(name:name)!
|
return get(name:name)!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(args FactoryArgs) !&SiteConfig {
|
pub fn get(args FactoryArgs) !&SiteConfig {
|
||||||
name := texttools.name_fix(args.name)
|
name := texttools.name_fix(args.name)
|
||||||
mut sc := siteconfigs[name] or {
|
mut sc := siteconfigs[name] or {
|
||||||
return error('siteconfig with name "${name}" does not exist')
|
return error('siteconfig with name "${name}" does not exist')
|
||||||
}
|
}
|
||||||
return sc
|
return sc
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default() !&SiteConfig {
|
pub fn default() !&SiteConfig {
|
||||||
if siteconfigs.len == 0 {
|
if siteconfigs.len == 0 {
|
||||||
return new(name:'default')!
|
return new(name:'default')!
|
||||||
}
|
}
|
||||||
return get()!
|
return get()!
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_heroscript_basics.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_heroscript_basics.md
|
||||||
@@ -541,53 +543,53 @@ HeroScript is a concise scripting language with the following structure:
|
|||||||
|
|
||||||
```heroscript
|
```heroscript
|
||||||
!!actor.action_name
|
!!actor.action_name
|
||||||
param1: 'value1'
|
param1: 'value1'
|
||||||
param2: 'value with spaces'
|
param2: 'value with spaces'
|
||||||
multiline_description: '
|
multiline_description: '
|
||||||
This is a multiline description.
|
This is a multiline description.
|
||||||
It can span multiple lines.
|
It can span multiple lines.
|
||||||
'
|
'
|
||||||
arg1 arg2 // Arguments without keys
|
arg1 arg2 // Arguments without keys
|
||||||
```
|
```
|
||||||
|
|
||||||
Key characteristics:
|
Key characteristics:
|
||||||
- **Actions**: Start with `!!`, followed by `actor.action_name` (e.g., `!!mailclient.configure`).
|
|
||||||
- **Parameters**: Defined as `key:value`. Values can be quoted for spaces.
|
- __Actions__: Start with `!!`, followed by `actor.action_name` (e.g., `!!mailclient.configure`).
|
||||||
- **Multiline Support**: Parameters like `description` can span multiple lines.
|
- __Parameters__: Defined as `key:value`. Values can be quoted for spaces.
|
||||||
- **Arguments**: Values without keys (e.g., `arg1`).
|
- __Multiline Support__: Parameters like `description` can span multiple lines.
|
||||||
|
- __Arguments__: Values without keys (e.g., `arg1`).
|
||||||
|
|
||||||
## Processing HeroScript in Vlang
|
## Processing HeroScript in Vlang
|
||||||
|
|
||||||
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters, this is used in most of the herolib modules, it allows configuration or actions in a structured way.
|
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters, this is used in most of the herolib modules, it allows configuration or actions in a structured way.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
import incubaid.herolib.core.playbook { PlayBook }
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
|
|
||||||
pub fn play(mut plbook PlayBook) ! {
|
pub fn play(mut plbook PlayBook) ! {
|
||||||
|
|
||||||
if plbook.exists_once(filter: 'docusaurus.define') {
|
if plbook.exists_once(filter: 'docusaurus.define') {
|
||||||
mut action := plbook.get(filter: 'docusaurus.define')!
|
mut action := plbook.get(filter: 'docusaurus.define')!
|
||||||
mut p := action.params
|
mut p := action.params
|
||||||
//example how we get parameters from the action see core_params.md for more details
|
//example how we get parameters from the action see core_params.md for more details
|
||||||
ds = new(
|
ds = new(
|
||||||
path: p.get_default('path_publish', '')!
|
path: p.get_default('path_publish', '')!
|
||||||
production: p.get_default_false('production')
|
production: p.get_default_false('production')
|
||||||
)!
|
)!
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process 'docusaurus.add' actions to configure individual Docusaurus sites
|
// Process 'docusaurus.add' actions to configure individual Docusaurus sites
|
||||||
actions := plbook.find(filter: 'docusaurus.add')!
|
actions := plbook.find(filter: 'docusaurus.add')!
|
||||||
for action in actions {
|
for action in actions {
|
||||||
mut p := action.params
|
mut p := action.params
|
||||||
//do more processing here
|
//do more processing here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
For detailed information on parameter retrieval methods (e.g., `p.get()`, `p.get_int()`, `p.get_default_true()`), refer to `aiprompts/ai_core/core_params.md`.
|
For detailed information on parameter retrieval methods (e.g., `p.get()`, `p.get_int()`, `p.get_default_true()`), refer to `aiprompts/ai_core/core_params.md`.
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_heroscript_playbook.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_heroscript_playbook.md
|
||||||
@@ -599,8 +601,8 @@ File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_h
|
|||||||
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters.
|
HeroScript can be parsed into a `playbook.PlayBook` object, allowing structured access to actions and their parameters.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import freeflowuniverse.herolib.core.playcmds
|
import incubaid.herolib.core.playcmds
|
||||||
|
|
||||||
// path string
|
// path string
|
||||||
// text string
|
// text string
|
||||||
@@ -616,8 +618,6 @@ playcmds.run(mut plbook)!
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_http_client.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_http_client.md
|
||||||
@@ -636,7 +636,7 @@ The `HTTPConnection` module provides a robust HTTP client for Vlang, supporting
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.httpconnection
|
import incubaid.herolib.core.httpconnection
|
||||||
|
|
||||||
// Create a new HTTP connection
|
// Create a new HTTP connection
|
||||||
mut conn := httpconnection.new(
|
mut conn := httpconnection.new(
|
||||||
@@ -654,17 +654,17 @@ To integrate `HTTPConnection` into a management class (e.g., `HetznerManager`),
|
|||||||
```v
|
```v
|
||||||
// Example: HetznerManager
|
// Example: HetznerManager
|
||||||
pub fn (mut h HetznerManager) connection() !&httpconnection.HTTPConnection {
|
pub fn (mut h HetznerManager) connection() !&httpconnection.HTTPConnection {
|
||||||
mut c := h.conn or {
|
mut c := h.conn or {
|
||||||
mut c2 := httpconnection.new(
|
mut c2 := httpconnection.new(
|
||||||
name: 'hetzner_${h.name}'
|
name: 'hetzner_${h.name}'
|
||||||
url: h.baseurl
|
url: h.baseurl
|
||||||
cache: true
|
cache: true
|
||||||
retry: 3
|
retry: 3
|
||||||
)!
|
)!
|
||||||
c2.basic_auth(h.user, h.password)
|
c2.basic_auth(h.user, h.password)
|
||||||
c2
|
c2
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -733,14 +733,15 @@ user := conn.get_json_generic[User](
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_osal.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_osal.md
|
||||||
|
|
||||||
```md
|
```md
|
||||||
# OSAL Core Module - Key Capabilities (freeflowuniverse.herolib.osal.core)
|
# OSAL Core Module - Key Capabilities (incubaid.herolib.osal.core)
|
||||||
|
|
||||||
|
|
||||||
```v
|
```v
|
||||||
//example how to get started
|
//example how to get started
|
||||||
|
|
||||||
import freeflowuniverse.herolib.osal.core as osal
|
import incubaid.herolib.osal.core as osal
|
||||||
|
|
||||||
osal.exec(cmd:"ls /")!
|
osal.exec(cmd:"ls /")!
|
||||||
|
|
||||||
@@ -752,50 +753,49 @@ this document has info about the most core functions, more detailed info can be
|
|||||||
|
|
||||||
### 1. Process Execution
|
### 1. Process Execution
|
||||||
|
|
||||||
* **`osal.exec(cmd: Command) !Job`**: Execute a shell command.
|
- __`osal.exec(cmd: Command) !Job`__: Execute a shell command.
|
||||||
* **Key Parameters**: `cmd` (string), `timeout` (int), `retry` (int), `work_folder` (string), `environment` (map[string]string), `stdout` (bool), `raise_error` (bool).
|
- __Key Parameters__: `cmd` (string), `timeout` (int), `retry` (int), `work_folder` (string), `environment` (map[string]string), `stdout` (bool), `raise_error` (bool).
|
||||||
* **Returns**: `Job` (status, output, error, exit code).
|
- __Returns__: `Job` (status, output, error, exit code).
|
||||||
* **`osal.execute_silent(cmd string) !string`**: Execute silently, return output.
|
- __`osal.execute_silent(cmd string) !string`__: Execute silently, return output.
|
||||||
* **`osal.cmd_exists(cmd string) bool`**: Check if a command exists.
|
- __`osal.cmd_exists(cmd string) bool`__: Check if a command exists.
|
||||||
* **`osal.process_kill_recursive(args: ProcessKillArgs) !`**: Kill a process and its children.
|
- __`osal.process_kill_recursive(args: ProcessKillArgs) !`__: Kill a process and its children.
|
||||||
|
|
||||||
### 2. Network Utilities
|
### 2. Network Utilities
|
||||||
|
|
||||||
* **`osal.ping(args: PingArgs) !bool`**: Check host reachability.
|
- __`osal.ping(args: PingArgs) !bool`__: Check host reachability.
|
||||||
* **`osal.tcp_port_test(args: TcpPortTestArgs) bool`**: Test if a TCP port is open.
|
- __`osal.tcp_port_test(args: TcpPortTestArgs) bool`__: Test if a TCP port is open.
|
||||||
* **Key Parameters**: `address` (string), `port` (int).
|
- __Key Parameters__: `address` (string), `port` (int).
|
||||||
* **`osal.ipaddr_pub_get() !string`**: Get public IP address.
|
- __`osal.ipaddr_pub_get() !string`__: Get public IP address.
|
||||||
|
|
||||||
### 3. File System Operations
|
### 3. File System Operations
|
||||||
|
|
||||||
* **`osal.file_write(path string, text string) !`**: Write text to a file.
|
- __`osal.file_write(path string, text string) !`__: Write text to a file.
|
||||||
* **`osal.file_read(path string) !string`**: Read content from a file.
|
- __`osal.file_read(path string) !string`__: Read content from a file.
|
||||||
* **`osal.dir_ensure(path string) !`**: Ensure a directory exists.
|
- __`osal.dir_ensure(path string) !`__: Ensure a directory exists.
|
||||||
* **`osal.rm(todelete string) !`**: Remove files/directories.
|
- __`osal.rm(todelete string) !`__: Remove files/directories.
|
||||||
|
|
||||||
### 4. Environment Variables
|
### 4. Environment Variables
|
||||||
|
|
||||||
* **`osal.env_set(args: EnvSet)`**: Set an environment variable.
|
- __`osal.env_set(args: EnvSet)`__: Set an environment variable.
|
||||||
* **Key Parameters**: `key` (string), `value` (string).
|
- __Key Parameters__: `key` (string), `value` (string).
|
||||||
* **`osal.env_get(key string) !string`**: Get an environment variable's value.
|
- __`osal.env_get(key string) !string`__: Get an environment variable's value.
|
||||||
* **`osal.load_env_file(file_path string) !`**: Load variables from a file.
|
- __`osal.load_env_file(file_path string) !`__: Load variables from a file.
|
||||||
|
|
||||||
### 5. Command & Profile Management
|
### 5. Command & Profile Management
|
||||||
|
|
||||||
* **`osal.cmd_add(args: CmdAddArgs) !`**: Add a binary to system paths and update profiles.
|
- __`osal.cmd_add(args: CmdAddArgs) !`__: Add a binary to system paths and update profiles.
|
||||||
* **Key Parameters**: `source` (string, required), `cmdname` (string).
|
- __Key Parameters__: `source` (string, required), `cmdname` (string).
|
||||||
* **`osal.profile_path_add_remove(args: ProfilePathAddRemoveArgs) !`**: Add/remove paths from profiles.
|
- __`osal.profile_path_add_remove(args: ProfilePathAddRemoveArgs) !`__: Add/remove paths from profiles.
|
||||||
* **Key Parameters**: `paths2add` (string), `paths2delete` (string).
|
- __Key Parameters__: `paths2add` (string), `paths2delete` (string).
|
||||||
|
|
||||||
### 6. System Information
|
### 6. System Information
|
||||||
|
|
||||||
* **`osal.platform() !PlatformType`**: Identify the operating system.
|
- __`osal.platform() !PlatformType`__: Identify the operating system.
|
||||||
* **`osal.cputype() !CPUType`**: Identify the CPU architecture.
|
- __`osal.cputype() !CPUType`__: Identify the CPU architecture.
|
||||||
* **`osal.hostname() !string`**: Get system hostname.
|
- __`osal.hostname() !string`__: Get system hostname.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_ourtime.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_ourtime.md
|
||||||
@@ -814,7 +814,7 @@ The `OurTime` module in V provides flexible time handling, supporting relative a
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
|
|
||||||
// Current time
|
// Current time
|
||||||
mut t := ourtime.now()
|
mut t := ourtime.now()
|
||||||
@@ -896,6 +896,7 @@ t_invalid := ourtime.new('bad-date') or {
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_params.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_params.md
|
||||||
|
|
||||||
```md
|
```md
|
||||||
# Parameter Parsing in Vlang
|
# Parameter Parsing in Vlang
|
||||||
|
|
||||||
@@ -904,7 +905,7 @@ This document details the `paramsparser` module, essential for handling paramete
|
|||||||
## Obtaining a `paramsparser` Instance
|
## Obtaining a `paramsparser` Instance
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.data.paramsparser
|
import incubaid.herolib.data.paramsparser
|
||||||
|
|
||||||
// Create new params from a string
|
// Create new params from a string
|
||||||
params := paramsparser.new("color:red size:'large' priority:1 enable:true")!
|
params := paramsparser.new("color:red size:'large' priority:1 enable:true")!
|
||||||
@@ -918,12 +919,13 @@ params.set("color", "red")
|
|||||||
|
|
||||||
The parser supports various input formats:
|
The parser supports various input formats:
|
||||||
|
|
||||||
1. **Key-value pairs**: `key:value`
|
1. __Key-value pairs__: `key:value`
|
||||||
2. **Quoted values**: `key:'value with spaces'` (single or double quotes)
|
2. __Quoted values__: `key:'value with spaces'` (single or double quotes)
|
||||||
3. **Arguments without keys**: `arg1 arg2` (accessed by index)
|
3. __Arguments without keys__: `arg1 arg2` (accessed by index)
|
||||||
4. **Comments**: `// this is a comment` (ignored during parsing)
|
4. __Comments__: `// this is a comment` (ignored during parsing)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := "name:'John Doe' age:30 active:true // user details"
|
text := "name:'John Doe' age:30 active:true // user details"
|
||||||
params := paramsparser.new(text)!
|
params := paramsparser.new(text)!
|
||||||
@@ -935,77 +937,77 @@ The `paramsparser` module provides a comprehensive set of methods for retrieving
|
|||||||
|
|
||||||
### Basic Retrieval
|
### Basic Retrieval
|
||||||
|
|
||||||
- `get(key string) !string`: Retrieves a string value by key. Returns an error if the key does not exist.
|
- `get(key string) !string`: Retrieves a string value by key. Returns an error if the key does not exist.
|
||||||
- `get_default(key string, defval string) !string`: Retrieves a string value by key, or returns `defval` if the key is not found.
|
- `get_default(key string, defval string) !string`: Retrieves a string value by key, or returns `defval` if the key is not found.
|
||||||
- `exists(key string) bool`: Checks if a keyword argument (`key:value`) exists.
|
- `exists(key string) bool`: Checks if a keyword argument (`key:value`) exists.
|
||||||
- `exists_arg(key string) bool`: Checks if an argument (value without a key) exists.
|
- `exists_arg(key string) bool`: Checks if an argument (value without a key) exists.
|
||||||
|
|
||||||
### Argument Retrieval (Positional)
|
### Argument Retrieval (Positional)
|
||||||
|
|
||||||
- `get_arg(nr int) !string`: Retrieves an argument by its 0-based index. Returns an error if the index is out of bounds.
|
- `get_arg(nr int) !string`: Retrieves an argument by its 0-based index. Returns an error if the index is out of bounds.
|
||||||
- `get_arg_default(nr int, defval string) !string`: Retrieves an argument by index, or returns `defval` if the index is out of bounds.
|
- `get_arg_default(nr int, defval string) !string`: Retrieves an argument by index, or returns `defval` if the index is out of bounds.
|
||||||
|
|
||||||
### Type-Specific Retrieval
|
### Type-Specific Retrieval
|
||||||
|
|
||||||
- `get_int(key string) !int`: Converts and retrieves an integer (int32).
|
- `get_int(key string) !int`: Converts and retrieves an integer (int32).
|
||||||
- `get_int_default(key string, defval int) !int`: Retrieves an integer with a default.
|
- `get_int_default(key string, defval int) !int`: Retrieves an integer with a default.
|
||||||
- `get_u32(key string) !u32`: Converts and retrieves an unsigned 32-bit integer.
|
- `get_u32(key string) !u32`: Converts and retrieves an unsigned 32-bit integer.
|
||||||
- `get_u32_default(key string, defval u32) !u32`: Retrieves a u32 with a default.
|
- `get_u32_default(key string, defval u32) !u32`: Retrieves a u32 with a default.
|
||||||
- `get_u64(key string) !u64`: Converts and retrieves an unsigned 64-bit integer.
|
- `get_u64(key string) !u64`: Converts and retrieves an unsigned 64-bit integer.
|
||||||
- `get_u64_default(key string, defval u64) !u64`: Retrieves a u64 with a default.
|
- `get_u64_default(key string, defval u64) !u64`: Retrieves a u64 with a default.
|
||||||
- `get_u8(key string) !u8`: Converts and retrieves an unsigned 8-bit integer.
|
- `get_u8(key string) !u8`: Converts and retrieves an unsigned 8-bit integer.
|
||||||
- `get_u8_default(key string, defval u8) !u8`: Retrieves a u8 with a default.
|
- `get_u8_default(key string, defval u8) !u8`: Retrieves a u8 with a default.
|
||||||
- `get_float(key string) !f64`: Converts and retrieves a 64-bit float.
|
- `get_float(key string) !f64`: Converts and retrieves a 64-bit float.
|
||||||
- `get_float_default(key string, defval f64) !f64`: Retrieves a float with a default.
|
- `get_float_default(key string, defval f64) !f64`: Retrieves a float with a default.
|
||||||
- `get_percentage(key string) !f64`: Converts a percentage string (e.g., "80%") to a float (0.8).
|
- `get_percentage(key string) !f64`: Converts a percentage string (e.g., "80%") to a float (0.8).
|
||||||
- `get_percentage_default(key string, defval string) !f64`: Retrieves a percentage with a default.
|
- `get_percentage_default(key string, defval string) !f64`: Retrieves a percentage with a default.
|
||||||
|
|
||||||
### Boolean Retrieval
|
### Boolean Retrieval
|
||||||
|
|
||||||
- `get_default_true(key string) bool`: Returns `true` if the value is empty, "1", "true", "y", or "yes". Otherwise `false`.
|
- `get_default_true(key string) bool`: Returns `true` if the value is empty, "1", "true", "y", or "yes". Otherwise `false`.
|
||||||
- `get_default_false(key string) bool`: Returns `false` if the value is empty, "0", "false", "n", or "no". Otherwise `true`.
|
- `get_default_false(key string) bool`: Returns `false` if the value is empty, "0", "false", "n", or "no". Otherwise `true`.
|
||||||
|
|
||||||
### List Retrieval
|
### List Retrieval
|
||||||
|
|
||||||
Lists are typically comma-separated strings (e.g., `users: "john,jane,bob"`).
|
Lists are typically comma-separated strings (e.g., `users: "john,jane,bob"`).
|
||||||
|
|
||||||
- `get_list(key string) ![]string`: Retrieves a list of strings.
|
- `get_list(key string) ![]string`: Retrieves a list of strings.
|
||||||
- `get_list_default(key string, def []string) ![]string`: Retrieves a list of strings with a default.
|
- `get_list_default(key string, def []string) ![]string`: Retrieves a list of strings with a default.
|
||||||
- `get_list_int(key string) ![]int`: Retrieves a list of integers.
|
- `get_list_int(key string) ![]int`: Retrieves a list of integers.
|
||||||
- `get_list_int_default(key string, def []int) []int`: Retrieves a list of integers with a default.
|
- `get_list_int_default(key string, def []int) []int`: Retrieves a list of integers with a default.
|
||||||
- `get_list_f32(key string) ![]f32`: Retrieves a list of 32-bit floats.
|
- `get_list_f32(key string) ![]f32`: Retrieves a list of 32-bit floats.
|
||||||
- `get_list_f32_default(key string, def []f32) []f32`: Retrieves a list of f32 with a default.
|
- `get_list_f32_default(key string, def []f32) []f32`: Retrieves a list of f32 with a default.
|
||||||
- `get_list_f64(key string) ![]f64`: Retrieves a list of 64-bit floats.
|
- `get_list_f64(key string) ![]f64`: Retrieves a list of 64-bit floats.
|
||||||
- `get_list_f64_default(key string, def []f64) []f64`: Retrieves a list of f64 with a default.
|
- `get_list_f64_default(key string, def []f64) []f64`: Retrieves a list of f64 with a default.
|
||||||
- `get_list_i8(key string) ![]i8`: Retrieves a list of 8-bit signed integers.
|
- `get_list_i8(key string) ![]i8`: Retrieves a list of 8-bit signed integers.
|
||||||
- `get_list_i8_default(key string, def []i8) []i8`: Retrieves a list of i8 with a default.
|
- `get_list_i8_default(key string, def []i8) []i8`: Retrieves a list of i8 with a default.
|
||||||
- `get_list_i16(key string) ![]i16`: Retrieves a list of 16-bit signed integers.
|
- `get_list_i16(key string) ![]i16`: Retrieves a list of 16-bit signed integers.
|
||||||
- `get_list_i16_default(key string, def []i16) []i16`: Retrieves a list of i16 with a default.
|
- `get_list_i16_default(key string, def []i16) []i16`: Retrieves a list of i16 with a default.
|
||||||
- `get_list_i64(key string) ![]i64`: Retrieves a list of 64-bit signed integers.
|
- `get_list_i64(key string) ![]i64`: Retrieves a list of 64-bit signed integers.
|
||||||
- `get_list_i64_default(key string, def []i64) []i64`: Retrieves a list of i64 with a default.
|
- `get_list_i64_default(key string, def []i64) []i64`: Retrieves a list of i64 with a default.
|
||||||
- `get_list_u16(key string) ![]u16`: Retrieves a list of 16-bit unsigned integers.
|
- `get_list_u16(key string) ![]u16`: Retrieves a list of 16-bit unsigned integers.
|
||||||
- `get_list_u16_default(key string, def []u16) []u16`: Retrieves a list of u16 with a default.
|
- `get_list_u16_default(key string, def []u16) []u16`: Retrieves a list of u16 with a default.
|
||||||
- `get_list_u32(key string) ![]u32`: Retrieves a list of 32-bit unsigned integers.
|
- `get_list_u32(key string) ![]u32`: Retrieves a list of 32-bit unsigned integers.
|
||||||
- `get_list_u32_default(key string, def []u32) []u32`: Retrieves a list of u32 with a default.
|
- `get_list_u32_default(key string, def []u32) []u32`: Retrieves a list of u32 with a default.
|
||||||
- `get_list_u64(key string) ![]u64`: Retrieves a list of 64-bit unsigned integers.
|
- `get_list_u64(key string) ![]u64`: Retrieves a list of 64-bit unsigned integers.
|
||||||
- `get_list_u64_default(key string, def []u64) []u64`: Retrieves a list of u64 with a default.
|
- `get_list_u64_default(key string, def []u64) []u64`: Retrieves a list of u64 with a default.
|
||||||
- `get_list_namefix(key string) ![]string`: Retrieves a list of strings, normalizing each item (e.g., "My Name" -> "my_name").
|
- `get_list_namefix(key string) ![]string`: Retrieves a list of strings, normalizing each item (e.g., "My Name" -> "my_name").
|
||||||
- `get_list_namefix_default(key string, def []string) ![]string`: Retrieves a list of name-fixed strings with a default.
|
- `get_list_namefix_default(key string, def []string) ![]string`: Retrieves a list of name-fixed strings with a default.
|
||||||
|
|
||||||
### Specialized Retrieval
|
### Specialized Retrieval
|
||||||
|
|
||||||
- `get_map() map[string]string`: Returns all parameters as a map.
|
- `get_map() map[string]string`: Returns all parameters as a map.
|
||||||
- `get_path(key string) !string`: Retrieves a path string.
|
- `get_path(key string) !string`: Retrieves a path string.
|
||||||
- `get_path_create(key string) !string`: Retrieves a path string, creating the directory if it doesn't exist.
|
- `get_path_create(key string) !string`: Retrieves a path string, creating the directory if it doesn't exist.
|
||||||
- `get_from_hashmap(key string, defval string, hashmap map[string]string) !string`: Retrieves a value from a provided hashmap based on the parameter's value.
|
- `get_from_hashmap(key string, defval string, hashmap map[string]string) !string`: Retrieves a value from a provided hashmap based on the parameter's value.
|
||||||
- `get_storagecapacity_in_bytes(key string) !u64`: Converts storage capacity strings (e.g., "10 GB", "500 MB") to bytes (u64).
|
- `get_storagecapacity_in_bytes(key string) !u64`: Converts storage capacity strings (e.g., "10 GB", "500 MB") to bytes (u64).
|
||||||
- `get_storagecapacity_in_bytes_default(key string, defval u64) !u64`: Retrieves storage capacity in bytes with a default.
|
- `get_storagecapacity_in_bytes_default(key string, defval u64) !u64`: Retrieves storage capacity in bytes with a default.
|
||||||
- `get_storagecapacity_in_gigabytes(key string) !u64`: Converts storage capacity strings to gigabytes (u64).
|
- `get_storagecapacity_in_gigabytes(key string) !u64`: Converts storage capacity strings to gigabytes (u64).
|
||||||
- `get_time(key string) !ourtime.OurTime`: Parses a time string (relative or absolute) into an `ourtime.OurTime` object.
|
- `get_time(key string) !ourtime.OurTime`: Parses a time string (relative or absolute) into an `ourtime.OurTime` object.
|
||||||
- `get_time_default(key string, defval ourtime.OurTime) !ourtime.OurTime`: Retrieves time with a default.
|
- `get_time_default(key string, defval ourtime.OurTime) !ourtime.OurTime`: Retrieves time with a default.
|
||||||
- `get_time_interval(key string) !Duration`: Parses a time interval string into a `Duration` object.
|
- `get_time_interval(key string) !Duration`: Parses a time interval string into a `Duration` object.
|
||||||
- `get_timestamp(key string) !Duration`: Parses a timestamp string into a `Duration` object.
|
- `get_timestamp(key string) !Duration`: Parses a timestamp string into a `Duration` object.
|
||||||
- `get_timestamp_default(key string, defval Duration) !Duration`: Retrieves a timestamp with a default.
|
- `get_timestamp_default(key string, defval Duration) !Duration`: Retrieves a timestamp with a default.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1028,10 +1030,11 @@ The pathlib module provides a comprehensive interface for handling file system o
|
|||||||
|
|
||||||
### Importing pathlib
|
### Importing pathlib
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
```
|
```
|
||||||
|
|
||||||
### Creating Path Objects
|
### Creating Path Objects
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Create a Path object for a file
|
// Create a Path object for a file
|
||||||
mut file_path := pathlib.get("path/to/file.txt")
|
mut file_path := pathlib.get("path/to/file.txt")
|
||||||
@@ -1041,6 +1044,7 @@ mut dir_path := pathlib.get("path/to/directory")
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Basic Path Operations
|
### Basic Path Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Get absolute path
|
// Get absolute path
|
||||||
abs_path := file_path.absolute()
|
abs_path := file_path.absolute()
|
||||||
@@ -1057,6 +1061,7 @@ if file_path.exists() {
|
|||||||
## Path Properties and Methods
|
## Path Properties and Methods
|
||||||
|
|
||||||
### Path Types
|
### Path Types
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Check if path is a file
|
// Check if path is a file
|
||||||
if file_path.is_file() {
|
if file_path.is_file() {
|
||||||
@@ -1075,6 +1080,7 @@ if file_path.is_link() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Path Normalization
|
### Path Normalization
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Normalize path (remove extra slashes, resolve . and ..)
|
// Normalize path (remove extra slashes, resolve . and ..)
|
||||||
normalized_path := file_path.path_normalize()
|
normalized_path := file_path.path_normalize()
|
||||||
@@ -1089,6 +1095,7 @@ name_no_ext := file_path.name_no_ext()
|
|||||||
## File and Directory Operations
|
## File and Directory Operations
|
||||||
|
|
||||||
### File Operations
|
### File Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Write to file
|
// Write to file
|
||||||
file_path.write("Content to write")!
|
file_path.write("Content to write")!
|
||||||
@@ -1101,6 +1108,7 @@ file_path.delete()!
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Directory Operations
|
### Directory Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Create directory
|
// Create directory
|
||||||
mut dir := pathlib.get_dir(
|
mut dir := pathlib.get_dir(
|
||||||
@@ -1116,6 +1124,7 @@ dir.delete()!
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Symlink Operations
|
### Symlink Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Create symlink
|
// Create symlink
|
||||||
file_path.link("path/to/symlink", delete_exists: true)!
|
file_path.link("path/to/symlink", delete_exists: true)!
|
||||||
@@ -1127,12 +1136,14 @@ real_path := file_path.realpath()
|
|||||||
## Advanced Operations
|
## Advanced Operations
|
||||||
|
|
||||||
### Path Copying
|
### Path Copying
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// Copy file to destination
|
// Copy file to destination
|
||||||
file_path.copy(dest: "path/to/destination")!
|
file_path.copy(dest: "path/to/destination")!
|
||||||
```
|
```
|
||||||
|
|
||||||
### Recursive Operations
|
### Recursive Operations
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// List directory recursively
|
// List directory recursively
|
||||||
mut recursive_list := dir.list(recursive: true)!
|
mut recursive_list := dir.list(recursive: true)!
|
||||||
@@ -1142,6 +1153,7 @@ dir.delete()!
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Path Filtering
|
### Path Filtering
|
||||||
|
|
||||||
```v
|
```v
|
||||||
// List files matching pattern
|
// List files matching pattern
|
||||||
mut filtered_list := dir.list(
|
mut filtered_list := dir.list(
|
||||||
@@ -1153,6 +1165,7 @@ mut filtered_list := dir.list(
|
|||||||
## Best Practices
|
## Best Practices
|
||||||
|
|
||||||
### Error Handling
|
### Error Handling
|
||||||
|
|
||||||
```v
|
```v
|
||||||
if file_path.exists() {
|
if file_path.exists() {
|
||||||
// Safe to operate
|
// Safe to operate
|
||||||
@@ -1161,7 +1174,6 @@ if file_path.exists() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_text.md
|
File: /Users/despiegk/code/github/incubaid/herolib/aiprompts/herolib_core/core_text.md
|
||||||
@@ -1173,93 +1185,121 @@ The `texttools` module provides a comprehensive set of utilities for text manipu
|
|||||||
## Functions and Examples:
|
## Functions and Examples:
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.core.texttools
|
import incubaid.herolib.core.texttools
|
||||||
|
|
||||||
assert hello_world == texttools.name_fix("Hello World!")
|
assert hello_world == texttools.name_fix("Hello World!")
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Name/Path Processing
|
### Name/Path Processing
|
||||||
* `name_fix(name string) string`: Normalizes filenames and paths.
|
|
||||||
* `name_fix_keepspace(name string) !string`: Like name_fix but preserves spaces.
|
* `name_fix(name string) string`: Normalizes filenames and paths.
|
||||||
* `name_fix_no_ext(name_ string) string`: Removes file extension.
|
- `name_fix_keepspace(name string) !string`: Like name_fix but preserves spaces.
|
||||||
* `name_fix_snake_to_pascal(name string) string`: Converts snake_case to PascalCase.
|
- `name_fix_no_ext(name_ string) string`: Removes file extension.
|
||||||
|
- `name_fix_snake_to_pascal(name string) string`: Converts snake_case to PascalCase.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
name := texttools.name_fix_snake_to_pascal("hello_world") // Result: "HelloWorld"
|
name := texttools.name_fix_snake_to_pascal("hello_world") // Result: "HelloWorld"
|
||||||
```
|
```
|
||||||
* `snake_case(name string) string`: Converts PascalCase to snake_case.
|
|
||||||
|
* `snake_case(name string) string`: Converts PascalCase to snake_case.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
name := texttools.snake_case("HelloWorld") // Result: "hello_world"
|
name := texttools.snake_case("HelloWorld") // Result: "hello_world"
|
||||||
```
|
```
|
||||||
* `name_split(name string) !(string, string)`: Splits name into site and page components.
|
|
||||||
|
|
||||||
|
* `name_split(name string) !(string, string)`: Splits name into site and page components.
|
||||||
|
|
||||||
### Text Cleaning
|
### Text Cleaning
|
||||||
* `name_clean(r string) string`: Normalizes names by removing special characters.
|
|
||||||
|
* `name_clean(r string) string`: Normalizes names by removing special characters.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
name := texttools.name_clean("Hello@World!") // Result: "HelloWorld"
|
name := texttools.name_clean("Hello@World!") // Result: "HelloWorld"
|
||||||
```
|
```
|
||||||
* `ascii_clean(r string) string`: Removes all non-ASCII characters.
|
|
||||||
* `remove_empty_lines(text string) string`: Removes empty lines from text.
|
* `ascii_clean(r string) string`: Removes all non-ASCII characters.
|
||||||
|
- `remove_empty_lines(text string) string`: Removes empty lines from text.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := texttools.remove_empty_lines("line1\n\nline2\n\n\nline3") // Result: "line1\nline2\nline3"
|
text := texttools.remove_empty_lines("line1\n\nline2\n\n\nline3") // Result: "line1\nline2\nline3"
|
||||||
```
|
```
|
||||||
* `remove_double_lines(text string) string`: Removes consecutive empty lines.
|
|
||||||
* `remove_empty_js_blocks(text string) string`: Removes empty code blocks (```...```).
|
* `remove_double_lines(text string) string`: Removes consecutive empty lines.
|
||||||
|
- `remove_empty_js_blocks(text string) string`: Removes empty code blocks (```...```).
|
||||||
|
|
||||||
### Command Line Parsing
|
### Command Line Parsing
|
||||||
* `cmd_line_args_parser(text string) ![]string`: Parses command line arguments with support for quotes and escaping.
|
|
||||||
|
* `cmd_line_args_parser(text string) ![]string`: Parses command line arguments with support for quotes and escaping.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
args := texttools.cmd_line_args_parser("'arg with spaces' --flag=value") // Result: ['arg with spaces', '--flag=value']
|
args := texttools.cmd_line_args_parser("'arg with spaces' --flag=value") // Result: ['arg with spaces', '--flag=value']
|
||||||
```
|
```
|
||||||
* `text_remove_quotes(text string) string`: Removes quoted sections from text.
|
|
||||||
* `check_exists_outside_quotes(text string, items []string) bool`: Checks if items exist in text outside of quotes.
|
* `text_remove_quotes(text string) string`: Removes quoted sections from text.
|
||||||
|
- `check_exists_outside_quotes(text string, items []string) bool`: Checks if items exist in text outside of quotes.
|
||||||
|
|
||||||
### Text Expansion
|
### Text Expansion
|
||||||
* `expand(txt_ string, l int, expand_with string) string`: Expands text to a specified length with a given character.
|
|
||||||
|
* `expand(txt_ string, l int, expand_with string) string`: Expands text to a specified length with a given character.
|
||||||
|
|
||||||
### Indentation
|
### Indentation
|
||||||
* `indent(text string, prefix string) string`: Adds indentation prefix to each line.
|
|
||||||
|
* `indent(text string, prefix string) string`: Adds indentation prefix to each line.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := texttools.indent("line1\nline2", " ") // Result: " line1\n line2\n"
|
text := texttools.indent("line1\nline2", " ") // Result: " line1\n line2\n"
|
||||||
```
|
```
|
||||||
* `dedent(text string) string`: Removes common leading whitespace from every line.
|
|
||||||
|
* `dedent(text string) string`: Removes common leading whitespace from every line.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := texttools.dedent(" line1\n line2") // Result: "line1\nline2"
|
text := texttools.dedent(" line1\n line2") // Result: "line1\nline2"
|
||||||
```
|
```
|
||||||
|
|
||||||
### String Validation
|
### String Validation
|
||||||
* `is_int(text string) bool`: Checks if text contains only digits.
|
|
||||||
* `is_upper_text(text string) bool`: Checks if text contains only uppercase letters.
|
* `is_int(text string) bool`: Checks if text contains only digits.
|
||||||
|
- `is_upper_text(text string) bool`: Checks if text contains only uppercase letters.
|
||||||
|
|
||||||
### Multiline Processing
|
### Multiline Processing
|
||||||
* `multiline_to_single(text string) !string`: Converts multiline text to a single line with proper escaping.
|
|
||||||
|
* `multiline_to_single(text string) !string`: Converts multiline text to a single line with proper escaping.
|
||||||
|
|
||||||
### Text Splitting
|
### Text Splitting
|
||||||
* `split_smart(t string, delimiter_ string) []string`: Intelligent string splitting that respects quotes.
|
|
||||||
|
* `split_smart(t string, delimiter_ string) []string`: Intelligent string splitting that respects quotes.
|
||||||
|
|
||||||
### Tokenization
|
### Tokenization
|
||||||
* `tokenize(text_ string) TokenizerResult`: Tokenizes text into meaningful parts.
|
|
||||||
* `text_token_replace(text string, tofind string, replacewith string) !string`: Replaces tokens in text.
|
* `tokenize(text_ string) TokenizerResult`: Tokenizes text into meaningful parts.
|
||||||
|
- `text_token_replace(text string, tofind string, replacewith string) !string`: Replaces tokens in text.
|
||||||
|
|
||||||
### Version Parsing
|
### Version Parsing
|
||||||
* `version(text_ string) int`: Converts version strings to comparable integers.
|
|
||||||
|
* `version(text_ string) int`: Converts version strings to comparable integers.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
ver := texttools.version("v0.4.36") // Result: 4036
|
ver := texttools.version("v0.4.36") // Result: 4036
|
||||||
ver = texttools.version("v1.4.36") // Result: 1004036
|
ver = texttools.version("v1.4.36") // Result: 1004036
|
||||||
```
|
```
|
||||||
|
|
||||||
### Formatting
|
### Formatting
|
||||||
* `format_rfc1123(t time.Time) string`: Formats a time.Time object into RFC 1123 format.
|
|
||||||
|
|
||||||
|
* `format_rfc1123(t time.Time) string`: Formats a time.Time object into RFC 1123 format.
|
||||||
|
|
||||||
### Array Operations
|
### Array Operations
|
||||||
* `to_array(r string) []string`: Converts a comma or newline separated list to an array of strings.
|
|
||||||
|
* `to_array(r string) []string`: Converts a comma or newline separated list to an array of strings.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
text := "item1,item2,item3"
|
text := "item1,item2,item3"
|
||||||
array := texttools.to_array(text) // Result: ['item1', 'item2', 'item3']
|
array := texttools.to_array(text) // Result: ['item1', 'item2', 'item3']
|
||||||
```
|
```
|
||||||
* `to_array_int(r string) []int`: Converts a text list to an array of integers.
|
|
||||||
* `to_map(mapstring string, line string, delimiter_ string) map[string]string`: Intelligent mapping of a line to a map based on a template.
|
* `to_array_int(r string) []int`: Converts a text list to an array of integers.
|
||||||
|
- `to_map(mapstring string, line string, delimiter_ string) map[string]string`: Intelligent mapping of a line to a map based on a template.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
r := texttools.to_map("name,-,-,-,-,pid,-,-,-,-,path",
|
r := texttools.to_map("name,-,-,-,-,pid,-,-,-,-,path",
|
||||||
"root 304 0.0 0.0 408185328 1360 ?? S 16Dec23 0:34.06 /usr/sbin/distnoted")
|
"root 304 0.0 0.0 408185328 1360 ?? S 16Dec23 0:34.06 /usr/sbin/distnoted")
|
||||||
@@ -1277,7 +1317,7 @@ has mechanisms to print better to console, see the methods below
|
|||||||
import as
|
import as
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1296,23 +1336,23 @@ fn color_fg(c ForegroundColor) string
|
|||||||
|
|
||||||
struct PrintArgs {
|
struct PrintArgs {
|
||||||
pub mut:
|
pub mut:
|
||||||
foreground ForegroundColor
|
foreground ForegroundColor
|
||||||
background BackgroundColor
|
background BackgroundColor
|
||||||
text string
|
text string
|
||||||
style Style
|
style Style
|
||||||
reset_before bool = true
|
reset_before bool = true
|
||||||
reset_after bool = true
|
reset_after bool = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cprint(args PrintArgs)
|
fn cprint(args PrintArgs)
|
||||||
// print with colors, reset...
|
// print with colors, reset...
|
||||||
// ```
|
// ```
|
||||||
// foreground ForegroundColor
|
// foreground ForegroundColor
|
||||||
// background BackgroundColor
|
// background BackgroundColor
|
||||||
// text string
|
// text string
|
||||||
// style Style
|
// style Style
|
||||||
// reset_before bool = true
|
// reset_before bool = true
|
||||||
// reset_after bool = true
|
// reset_after bool = true
|
||||||
// ```
|
// ```
|
||||||
|
|
||||||
fn cprintln(args_ PrintArgs)
|
fn cprintln(args_ PrintArgs)
|
||||||
@@ -1367,11 +1407,11 @@ Is used to ask feedback to users
|
|||||||
|
|
||||||
struct UIConsole {
|
struct UIConsole {
|
||||||
pub mut:
|
pub mut:
|
||||||
x_max int = 80
|
x_max int = 80
|
||||||
y_max int = 60
|
y_max int = 60
|
||||||
prev_lf bool
|
prev_lf bool
|
||||||
prev_title bool
|
prev_title bool
|
||||||
prev_item bool
|
prev_item bool
|
||||||
}
|
}
|
||||||
|
|
||||||
//DropDownArgs:
|
//DropDownArgs:
|
||||||
@@ -1422,51 +1462,51 @@ fn (mut c UIConsole) status() string
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
enum BackgroundColor {
|
enum BackgroundColor {
|
||||||
default_color = 49 // 'default' is a reserved keyword in V
|
default_color = 49 // 'default' is a reserved keyword in V
|
||||||
black = 40
|
black = 40
|
||||||
red = 41
|
red = 41
|
||||||
green = 42
|
green = 42
|
||||||
yellow = 43
|
yellow = 43
|
||||||
blue = 44
|
blue = 44
|
||||||
magenta = 45
|
magenta = 45
|
||||||
cyan = 46
|
cyan = 46
|
||||||
light_gray = 47
|
light_gray = 47
|
||||||
dark_gray = 100
|
dark_gray = 100
|
||||||
light_red = 101
|
light_red = 101
|
||||||
light_green = 102
|
light_green = 102
|
||||||
light_yellow = 103
|
light_yellow = 103
|
||||||
light_blue = 104
|
light_blue = 104
|
||||||
light_magenta = 105
|
light_magenta = 105
|
||||||
light_cyan = 106
|
light_cyan = 106
|
||||||
white = 107
|
white = 107
|
||||||
}
|
}
|
||||||
enum ForegroundColor {
|
enum ForegroundColor {
|
||||||
default_color = 39 // 'default' is a reserved keyword in V
|
default_color = 39 // 'default' is a reserved keyword in V
|
||||||
white = 97
|
white = 97
|
||||||
black = 30
|
black = 30
|
||||||
red = 31
|
red = 31
|
||||||
green = 32
|
green = 32
|
||||||
yellow = 33
|
yellow = 33
|
||||||
blue = 34
|
blue = 34
|
||||||
magenta = 35
|
magenta = 35
|
||||||
cyan = 36
|
cyan = 36
|
||||||
light_gray = 37
|
light_gray = 37
|
||||||
dark_gray = 90
|
dark_gray = 90
|
||||||
light_red = 91
|
light_red = 91
|
||||||
light_green = 92
|
light_green = 92
|
||||||
light_yellow = 93
|
light_yellow = 93
|
||||||
light_blue = 94
|
light_blue = 94
|
||||||
light_magenta = 95
|
light_magenta = 95
|
||||||
light_cyan = 96
|
light_cyan = 96
|
||||||
}
|
}
|
||||||
enum Style {
|
enum Style {
|
||||||
normal = 99
|
normal = 99
|
||||||
bold = 1
|
bold = 1
|
||||||
dim = 2
|
dim = 2
|
||||||
underline = 4
|
underline = 4
|
||||||
blink = 5
|
blink = 5
|
||||||
reverse = 7
|
reverse = 7
|
||||||
hidden = 8
|
hidden = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -1482,7 +1522,7 @@ this is how we want example scripts to be, see the first line
|
|||||||
```v
|
```v
|
||||||
#!/usr/bin/env -S v -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib...
|
import incubaid.herolib...
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1688,6 +1728,7 @@ impl Company {
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/mod.rs
|
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/mod.rs
|
||||||
|
|
||||||
```rs
|
```rs
|
||||||
// Business models module
|
// Business models module
|
||||||
// Sub-modules will be declared here
|
// Sub-modules will be declared here
|
||||||
@@ -1712,6 +1753,7 @@ pub use sale::{Sale, SaleItem, SaleStatus};
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/payment.rs
|
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/payment.rs
|
||||||
|
|
||||||
```rs
|
```rs
|
||||||
use heromodels_core::BaseModelData;
|
use heromodels_core::BaseModelData;
|
||||||
use heromodels_derive::model;
|
use heromodels_derive::model;
|
||||||
@@ -1933,6 +1975,7 @@ impl Payment {
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/product.rs
|
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/product.rs
|
||||||
|
|
||||||
```rs
|
```rs
|
||||||
use heromodels_core::BaseModelData;
|
use heromodels_core::BaseModelData;
|
||||||
use heromodels_derive::model;
|
use heromodels_derive::model;
|
||||||
@@ -2086,6 +2129,7 @@ impl Product {
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/README.md
|
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/README.md
|
||||||
|
|
||||||
```md
|
```md
|
||||||
# Business Models (`biz`)
|
# Business Models (`biz`)
|
||||||
|
|
||||||
@@ -2149,6 +2193,7 @@ All models use the builder pattern for easy and readable instance creation.
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/sale.rs
|
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/sale.rs
|
||||||
|
|
||||||
```rs
|
```rs
|
||||||
use heromodels_core::{BaseModelData, BaseModelDataOps, Model};
|
use heromodels_core::{BaseModelData, BaseModelDataOps, Model};
|
||||||
use rhai::{CustomType, TypeBuilder};
|
use rhai::{CustomType, TypeBuilder};
|
||||||
@@ -2326,6 +2371,7 @@ impl Sale {
|
|||||||
```
|
```
|
||||||
|
|
||||||
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/shareholder.rs
|
File: /Users/despiegk/code/git.threefold.info/herocode/db/heromodels/src/models/biz/shareholder.rs
|
||||||
|
|
||||||
```rs
|
```rs
|
||||||
use heromodels_core::BaseModelData;
|
use heromodels_core::BaseModelData;
|
||||||
use heromodels_derive::model;
|
use heromodels_derive::model;
|
||||||
@@ -2410,6 +2456,7 @@ impl Shareholder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</file_contents>
|
</file_contents>
|
||||||
<meta prompt 1 = "[Architect]">
|
<meta prompt 1 = "[Architect]">
|
||||||
You are a senior software architect specializing in code design and implementation planning. Your role is to:
|
You are a senior software architect specializing in code design and implementation planning. Your role is to:
|
||||||
@@ -2425,6 +2472,7 @@ You are a senior software architect specializing in code design and implementati
|
|||||||
- Configuration updates
|
- Configuration updates
|
||||||
|
|
||||||
For each change:
|
For each change:
|
||||||
|
|
||||||
- Describe the exact location in the code where changes are needed
|
- Describe the exact location in the code where changes are needed
|
||||||
- Explain the logic and reasoning behind each modification
|
- Explain the logic and reasoning behind each modification
|
||||||
- Provide example signatures, parameters, and return types
|
- Provide example signatures, parameters, and return types
|
||||||
@@ -2448,7 +2496,6 @@ forget what rust does, there is no special module things needed, no re-exports o
|
|||||||
|
|
||||||
there is no defaults for empty strings or 0 ints, … defaults are only for non empty stuff
|
there is no defaults for empty strings or 0 ints, … defaults are only for non empty stuff
|
||||||
|
|
||||||
|
|
||||||
</meta prompt 2>
|
</meta prompt 2>
|
||||||
<user_instructions>
|
<user_instructions>
|
||||||
$NAME = finance
|
$NAME = finance
|
||||||
@@ -2472,6 +2519,4 @@ at top of each file we have ```module $NAME```
|
|||||||
|
|
||||||
don't create management classes, only output the structs
|
don't create management classes, only output the structs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</user_instructions>
|
</user_instructions>
|
||||||
|
|||||||
@@ -17,16 +17,14 @@ don't do anything additional for modules, don't do import
|
|||||||
|
|
||||||
at top of each file we have ```module $NAME```
|
at top of each file we have ```module $NAME```
|
||||||
|
|
||||||
|
|
||||||
make sure all time related fields are in u64 format, use unix timestamp for that
|
make sure all time related fields are in u64 format, use unix timestamp for that
|
||||||
|
|
||||||
don't create management classes, only output the structs, don't create a mod.v, don't make .v scripts executatble, don't create a main.v
|
don't create management classes, only output the structs, don't create a mod.v, don't make .v scripts executatble, don't create a main.v
|
||||||
|
|
||||||
|
|
||||||
## now also make sure we use core.base as follows
|
## now also make sure we use core.base as follows
|
||||||
|
|
||||||
```
|
```
|
||||||
import freeflowuniverse.herolib.hero.models.core
|
import incubaid.herolib.hero.models.core
|
||||||
|
|
||||||
// Account represents a financial account for tracking balances and transactions
|
// Account represents a financial account for tracking balances and transactions
|
||||||
// Supports multiple account types (checking, savings, investment, etc.)
|
// Supports multiple account types (checking, savings, investment, etc.)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ for governance and legal
|
|||||||
|
|
||||||
make sure we use core.base as follows
|
make sure we use core.base as follows
|
||||||
|
|
||||||
import freeflowuniverse.herolib.hero.models.core
|
import incubaid.herolib.hero.models.core
|
||||||
|
|
||||||
// Account represents a financial account for tracking balances and transactions
|
// Account represents a financial account for tracking balances and transactions
|
||||||
// Supports multiple account types (checking, savings, investment, etc.)
|
// Supports multiple account types (checking, savings, investment, etc.)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
19
cli/hero.v
19
cli/hero.v
@@ -2,14 +2,14 @@ module main
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import cli { Command }
|
import cli { Command }
|
||||||
import freeflowuniverse.herolib.core.herocmds
|
import incubaid.herolib.core.herocmds
|
||||||
import freeflowuniverse.herolib.installers.base
|
import incubaid.herolib.installers.base
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
import freeflowuniverse.herolib.ui
|
import incubaid.herolib.ui
|
||||||
import freeflowuniverse.herolib.osal.core as osal
|
import incubaid.herolib.osal.core as osal
|
||||||
import freeflowuniverse.herolib.core
|
import incubaid.herolib.core
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import freeflowuniverse.herolib.core.playcmds
|
import incubaid.herolib.core.playcmds
|
||||||
|
|
||||||
fn playcmds_do(path string) ! {
|
fn playcmds_do(path string) ! {
|
||||||
mut plbook := playbook.new(path: path)!
|
mut plbook := playbook.new(path: path)!
|
||||||
@@ -38,7 +38,8 @@ fn do() ! {
|
|||||||
|
|
||||||
if os.args.len == 2 {
|
if os.args.len == 2 {
|
||||||
mypath := os.args[1]
|
mypath := os.args[1]
|
||||||
if mypath.to_lower().ends_with('.hero') || mypath.to_lower().ends_with('.heroscript') || mypath.to_lower().ends_with('.hs') {
|
if mypath.to_lower().ends_with('.hero') || mypath.to_lower().ends_with('.heroscript')
|
||||||
|
|| mypath.to_lower().ends_with('.hs') {
|
||||||
// hero was called from a file
|
// hero was called from a file
|
||||||
playcmds_do(mypath)!
|
playcmds_do(mypath)!
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
import freeflowuniverse.herolib.mcp.v_do
|
import incubaid.herolib.mcp.v_do
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Create and start the MCP server
|
// Create and start the MCP server
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ println('Resetting all symlinks...')
|
|||||||
os.rm('${os.home_dir()}/.vmodules/incubaid/herolib') or {}
|
os.rm('${os.home_dir()}/.vmodules/incubaid/herolib') or {}
|
||||||
|
|
||||||
// Create necessary directories
|
// Create necessary directories
|
||||||
os.mkdir_all('${os.home_dir()}/.vmodules/freeflowuniverse') or {
|
os.mkdir_all('${os.home_dir()}/.vmodules/incubaid') or {
|
||||||
panic('Failed to create directory ~/.vmodules/freeflowuniverse: ${err}')
|
panic('Failed to create directory ~/.vmodules/incubaid: ${err}')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new symlinks
|
// Create new symlinks
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ function hero_lib_get {
|
|||||||
hero_lib_pull
|
hero_lib_pull
|
||||||
else
|
else
|
||||||
pushd $DIR_CODE/github/incubaid 2>&1 >> /dev/null
|
pushd $DIR_CODE/github/incubaid 2>&1 >> /dev/null
|
||||||
git clone --depth 1 --no-single-branch https://github.com/freeflowuniverse/herolib.git
|
git clone --depth 1 --no-single-branch https://github.com/incubaid/herolib.git
|
||||||
popd 2>&1 >> /dev/null
|
popd 2>&1 >> /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module main
|
module main
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.openai
|
import incubaid.herolib.clients.openai
|
||||||
import os
|
import os
|
||||||
|
|
||||||
fn test1(mut client openai.OpenAI) ! {
|
fn test1(mut client openai.OpenAI) ! {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.mcp.aitools
|
import incubaid.herolib.mcp.aitools
|
||||||
|
|
||||||
// aitools.convert_pug("/root/code/github/incubaid/herolauncher/pkg/herolauncher/web/templates/admin")!
|
// aitools.convert_pug("/root/code/github/incubaid/herolauncher/pkg/herolauncher/web/templates/admin")!
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.jina
|
import incubaid.herolib.clients.jina
|
||||||
|
|
||||||
mut jina_client := jina.get()!
|
mut jina_client := jina.get()!
|
||||||
health := jina_client.health()!
|
health := jina_client.health()!
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.qdrant
|
import incubaid.herolib.clients.qdrant
|
||||||
import freeflowuniverse.herolib.installers.db.qdrant_installer
|
import incubaid.herolib.installers.db.qdrant_installer
|
||||||
import freeflowuniverse.herolib.core.httpconnection
|
import incubaid.herolib.core.httpconnection
|
||||||
import rand
|
import rand
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.hero.bootstrap
|
import incubaid.herolib.hero.bootstrap
|
||||||
|
|
||||||
mut al := bootstrap.new_alpine_loader()
|
mut al := bootstrap.new_alpine_loader()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.investortool
|
import incubaid.herolib.biz.investortool
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
mut plbook := playbook.new(
|
mut plbook := playbook.new(
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#!/usr/bin/env -S v -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
// #!/usr/bin/env -S v -cg -enable-globals run
|
// #!/usr/bin/env -S v -cg -enable-globals run
|
||||||
import freeflowuniverse.herolib.data.doctree
|
import incubaid.herolib.data.doctree
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import freeflowuniverse.herolib.core.playcmds
|
import incubaid.herolib.core.playcmds
|
||||||
import freeflowuniverse.herolib.web.mdbook
|
import incubaid.herolib.web.mdbook
|
||||||
import freeflowuniverse.herolib.biz.spreadsheet
|
import incubaid.herolib.biz.spreadsheet
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const name = 'tf9_budget'
|
const name = 'tf9_budget'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const playbook_path = os.dir(@FILE) + '/playbook'
|
const playbook_path = os.dir(@FILE) + '/playbook'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript_path := os.join_path(os.dir(@FILE), 'examples/complete.heroscript')
|
heroscript_path := os.join_path(os.dir(@FILE), 'examples/complete.heroscript')
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import freeflowuniverse.herolib.core.playcmds
|
import incubaid.herolib.core.playcmds
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript_path := os.join_path(os.dir(@FILE), 'examples/complete.heroscript')
|
heroscript_path := os.join_path(os.dir(@FILE), 'examples/complete.heroscript')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript_path := os.join_path(os.dir(@FILE), 'examples/full')
|
heroscript_path := os.join_path(os.dir(@FILE), 'examples/full')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import incubaid.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import os
|
import os
|
||||||
|
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ A V program that demonstrates remote execution of system operations:
|
|||||||
### `run.sh`
|
### `run.sh`
|
||||||
|
|
||||||
A bash script that:
|
A bash script that:
|
||||||
|
|
||||||
1. Compiles the V program
|
1. Compiles the V program
|
||||||
2. Copies it to a remote machine using SCP
|
2. Copies it to a remote machine using SCP
|
||||||
3. Executes it remotely using SSH
|
3. Executes it remotely using SSH
|
||||||
@@ -45,16 +46,19 @@ Modify these values to match your remote system configuration.
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
1. Set the required environment variable:
|
1. Set the required environment variable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export SECRET=your_secret_value
|
export SECRET=your_secret_value
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Make the script executable:
|
2. Make the script executable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
chmod +x run.sh
|
chmod +x run.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Run the script:
|
3. Run the script:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./run.sh
|
./run.sh
|
||||||
```
|
```
|
||||||
@@ -66,9 +70,8 @@ This example demonstrates practical usage of the herolib builder module's remote
|
|||||||
The builder module provides a more structured way to manage remote nodes and execute commands:
|
The builder module provides a more structured way to manage remote nodes and execute commands:
|
||||||
|
|
||||||
```v
|
```v
|
||||||
import freeflowuniverse.herolib.builder
|
import incubaid.herolib.builder
|
||||||
mut b := builder.new()!
|
mut b := builder.new()!
|
||||||
mut n := b.node_new(ipaddr:"user@host:port")!
|
mut n := b.node_new(ipaddr:"user@host:port")!
|
||||||
// Execute commands on the remote node
|
// Execute commands on the remote node
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core
|
import incubaid.herolib.core
|
||||||
|
|
||||||
fn do() ! {
|
fn do() ! {
|
||||||
// base.uninstall_brew()!
|
// base.uninstall_brew()!
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.builder
|
import incubaid.herolib.builder
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
fn do1() ! {
|
fn do1() ! {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.builder
|
import incubaid.herolib.builder
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
mut b := builder.new()!
|
mut b := builder.new()!
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.builder
|
import incubaid.herolib.builder
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
mut b := builder.new()!
|
mut b := builder.new()!
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.openai
|
import incubaid.herolib.clients.openai
|
||||||
import freeflowuniverse.herolib.core.playcmds
|
import incubaid.herolib.core.playcmds
|
||||||
|
|
||||||
playcmds.run(
|
playcmds.run(
|
||||||
heroscript: '
|
heroscript: '
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -g -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -g -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.playcmds
|
import incubaid.herolib.core.playcmds
|
||||||
import freeflowuniverse.herolib.clients.giteaclient
|
import incubaid.herolib.clients.giteaclient
|
||||||
|
|
||||||
heroscript := "
|
heroscript := "
|
||||||
!!giteaclient.configure
|
!!giteaclient.configure
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.jina
|
import incubaid.herolib.clients.jina
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.mailclient
|
import incubaid.herolib.clients.mailclient
|
||||||
|
|
||||||
// remove the previous one, otherwise the env variables are not read
|
// remove the previous one, otherwise the env variables are not read
|
||||||
mailclient.config_delete(name: 'test')!
|
mailclient.config_delete(name: 'test')!
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.mycelium
|
import incubaid.herolib.clients.mycelium
|
||||||
import freeflowuniverse.herolib.installers.net.mycelium_installer
|
import incubaid.herolib.installers.net.mycelium_installer
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import encoding.base64
|
import encoding.base64
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
// Mycelium RPC Client Example
|
// Mycelium RPC Client Example
|
||||||
// This example demonstrates how to use the new Mycelium JSON-RPC client
|
// This example demonstrates how to use the new Mycelium JSON-RPC client
|
||||||
// to interact with a Mycelium node's admin API
|
// to interact with a Mycelium node's admin API
|
||||||
import freeflowuniverse.herolib.clients.mycelium_rpc
|
import incubaid.herolib.clients.mycelium_rpc
|
||||||
import freeflowuniverse.herolib.installers.net.mycelium_installer
|
import incubaid.herolib.installers.net.mycelium_installer
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import encoding.base64
|
import encoding.base64
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core
|
import incubaid.herolib.core
|
||||||
import freeflowuniverse.herolib.clients.postgresql_client
|
import incubaid.herolib.clients.postgresql_client
|
||||||
|
|
||||||
// Configure PostgreSQL client
|
// Configure PostgreSQL client
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.zinit
|
import incubaid.herolib.clients.zinit
|
||||||
import freeflowuniverse.herolib.installers.infra.zinit_installer
|
import incubaid.herolib.installers.infra.zinit_installer
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
import freeflowuniverse.herolib.core.jobs.model
|
import incubaid.herolib.core.jobs.model
|
||||||
|
|
||||||
// Create a test agent with some sample data
|
// Create a test agent with some sample data
|
||||||
mut agent := model.Agent{
|
mut agent := model.Agent{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.base
|
import incubaid.herolib.core.base
|
||||||
|
|
||||||
pub struct MyClient[T] {
|
pub struct MyClient[T] {
|
||||||
base.BaseConfig[T]
|
base.BaseConfig[T]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import freeflowuniverse.herolib.core.base
|
import incubaid.herolib.core.base
|
||||||
|
|
||||||
pub struct MyClient[T] {
|
pub struct MyClient[T] {
|
||||||
base.BaseConfig[T]
|
base.BaseConfig[T]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.base
|
import incubaid.herolib.core.base
|
||||||
import freeflowuniverse.herolib.develop.gittools
|
import incubaid.herolib.develop.gittools
|
||||||
|
|
||||||
pub struct MyClass {
|
pub struct MyClass {
|
||||||
base.Base
|
base.Base
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env -S v -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import freeflowuniverse.herolib.core.smartid
|
import incubaid.herolib.core.smartid
|
||||||
import freeflowuniverse.herolib.data.ourtime
|
import incubaid.herolib.data.ourtime
|
||||||
import freeflowuniverse.herolib.core.db
|
import incubaid.herolib.core.db
|
||||||
|
|
||||||
pub struct MyStruct {
|
pub struct MyStruct {
|
||||||
db.Base
|
db.Base
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.generator.generic as generator
|
import incubaid.herolib.core.generator.generic as generator
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
|
|
||||||
// mut args := generator.GeneratorArgs{
|
// mut args := generator.GeneratorArgs{
|
||||||
// path: '~/code/github/incubaid/herolib/lib/clients'
|
// path: '~/code/github/incubaid/herolib/lib/clients'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.logger
|
import incubaid.herolib.core.logger
|
||||||
|
|
||||||
mut l := logger.new(path: '/tmp/vlogs')!
|
mut l := logger.new(path: '/tmp/vlogs')!
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import freeflowuniverse.herolib.core.openapi.gen
|
import incubaid.herolib.core.openapi.gen
|
||||||
|
|
||||||
const spec_path = '${os.dir(@FILE)}/openapi.json'
|
const spec_path = '${os.dir(@FILE)}/openapi.json'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module openrpc_client
|
module openrpc_client
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.jsonrpc { JsonRpcRequest }
|
import incubaid.herolib.data.jsonrpc { JsonRpcRequest }
|
||||||
import net.websocket
|
import net.websocket
|
||||||
|
|
||||||
struct Client {
|
struct Client {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module petstore_client
|
module petstore_client
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.jsonrpc { JsonRpcRequest }
|
import incubaid.herolib.data.jsonrpc { JsonRpcRequest }
|
||||||
import net.websocket
|
import net.websocket
|
||||||
|
|
||||||
struct Client {
|
struct Client {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module petstore_client
|
module petstore_client
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.jsonrpc
|
import incubaid.herolib.data.jsonrpc
|
||||||
|
|
||||||
// get_pets finds pets in the system that the user has access to by tags and within a limit
|
// get_pets finds pets in the system that the user has access to by tags and within a limit
|
||||||
// - tags: tags to filter by
|
// - tags: tags to filter by
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const testpath3 = os.dir(@FILE) + '/../../..'
|
const testpath3 = os.dir(@FILE) + '/../../..'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const testpath4 = os.dir(@FILE) + '../../'
|
const testpath4 = os.dir(@FILE) + '../../'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import freeflowuniverse.herolib.data.paramsparser
|
import incubaid.herolib.data.paramsparser
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const testpath3 = os.dir(@FILE) + '/../..'
|
const testpath3 = os.dir(@FILE) + '/../..'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import incubaid.herolib.core.pathlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const testpath4 = os.dir(@FILE) + '/paths_sha256.vsh'
|
const testpath4 = os.dir(@FILE) + '/paths_sha256.vsh'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals -no-skip-unused run
|
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals -no-skip-unused run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.crypt.herocrypt
|
import incubaid.herolib.crypt.herocrypt
|
||||||
import time
|
import time
|
||||||
|
|
||||||
// Initialize the HeroCrypt client
|
// Initialize the HeroCrypt client
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v run
|
#!/usr/bin/env -S v run
|
||||||
|
|
||||||
// Example struct to cache
|
// Example struct to cache
|
||||||
import freeflowuniverse.herolib.data.cache
|
import incubaid.herolib.data.cache
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@[heap]
|
@[heap]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.countries
|
import incubaid.herolib.data.countries
|
||||||
|
|
||||||
mut all_countries := countries.get_all_countries() or {
|
mut all_countries := countries.get_all_countries() or {
|
||||||
eprintln('Error loading countries: ${err}')
|
eprintln('Error loading countries: ${err}')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourdb
|
import incubaid.herolib.data.ourdb
|
||||||
import time
|
import time
|
||||||
|
|
||||||
// Known worker public key
|
// Known worker public key
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourdb
|
import incubaid.herolib.data.ourdb
|
||||||
|
|
||||||
worker_public_key := '46a9f9cee1ce98ef7478f3dea759589bbf6da9156533e63fed9f233640ac072c'
|
worker_public_key := '46a9f9cee1ce98ef7478f3dea759589bbf6da9156533e63fed9f233640ac072c'
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.encoder
|
import incubaid.herolib.data.encoder
|
||||||
import crypto.ed25519
|
import crypto.ed25519
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
|
|
||||||
struct AStruct {
|
struct AStruct {
|
||||||
mut:
|
mut:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.crypt.aes_symmetric { decrypt, encrypt }
|
import incubaid.herolib.crypt.aes_symmetric { decrypt, encrypt }
|
||||||
import freeflowuniverse.herolib.ui.console
|
import incubaid.herolib.ui.console
|
||||||
|
|
||||||
msg := 'my message'.bytes()
|
msg := 'my message'.bytes()
|
||||||
console.print_debug('${msg}')
|
console.print_debug('${msg}')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
// Example demonstrating GraphDB usage in a social network context
|
// Example demonstrating GraphDB usage in a social network context
|
||||||
import freeflowuniverse.herolib.data.graphdb
|
import incubaid.herolib.data.graphdb
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Initialize a new graph database with default cache settings
|
// Initialize a new graph database with default cache settings
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.encoderhero
|
import incubaid.herolib.data.encoderhero
|
||||||
import freeflowuniverse.herolib.core.base
|
import incubaid.herolib.core.base
|
||||||
|
|
||||||
// this is docu at top
|
// this is docu at top
|
||||||
@[name: 'teststruct ']
|
@[name: 'teststruct ']
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.encoderhero
|
import incubaid.herolib.data.encoderhero
|
||||||
import freeflowuniverse.herolib.core.base
|
import incubaid.herolib.core.base
|
||||||
import time
|
import time
|
||||||
|
|
||||||
struct Person {
|
struct Person {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -cg -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -cg -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.postgresql_client
|
import incubaid.herolib.clients.postgresql_client
|
||||||
import freeflowuniverse.herolib.data.location
|
import incubaid.herolib.data.location
|
||||||
|
|
||||||
// Configure PostgreSQL client
|
// Configure PostgreSQL client
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.clients.postgresql_client
|
import incubaid.herolib.clients.postgresql_client
|
||||||
import freeflowuniverse.herolib.data.location
|
import incubaid.herolib.data.location
|
||||||
|
|
||||||
// Configure PostgreSQL client
|
// Configure PostgreSQL client
|
||||||
heroscript := "
|
heroscript := "
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// Please note that before running this script you need to run the server first
|
// Please note that before running this script you need to run the server first
|
||||||
// See examples/data/ourdb_server.vsh
|
// See examples/data/ourdb_server.vsh
|
||||||
import freeflowuniverse.herolib.data.ourdb
|
import incubaid.herolib.data.ourdb
|
||||||
import os
|
import os
|
||||||
|
|
||||||
mut client := ourdb.new_client(
|
mut client := ourdb.new_client(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourdb
|
import incubaid.herolib.data.ourdb
|
||||||
|
|
||||||
const test_dir = '/tmp/ourdb'
|
const test_dir = '/tmp/ourdb'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourdb
|
import incubaid.herolib.data.ourdb
|
||||||
import os
|
import os
|
||||||
|
|
||||||
mut server := ourdb.new_server(
|
mut server := ourdb.new_server(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourdb_syncer.streamer
|
import incubaid.herolib.data.ourdb_syncer.streamer
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
master_public_key := '570c1069736786f06c4fd2a6dc6c17cd88347604593b60e34b5688c369fa1b39'
|
master_public_key := '570c1069736786f06c4fd2a6dc6c17cd88347604593b60e34b5688c369fa1b39'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourdb_syncer.streamer
|
import incubaid.herolib.data.ourdb_syncer.streamer
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println('Strating the streamer first!')
|
println('Strating the streamer first!')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.ourdb_syncer.streamer
|
import incubaid.herolib.data.ourdb_syncer.streamer
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Create a new streamer
|
// Create a new streamer
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import incubaid.herolib.core.playbook
|
||||||
import freeflowuniverse.herolib.data.paramsparser
|
import incubaid.herolib.data.paramsparser
|
||||||
import os
|
import os
|
||||||
|
|
||||||
const testpath = os.dir(@FILE) + '/data'
|
const testpath = os.dir(@FILE) + '/data'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.paramsparser { Params, parse }
|
import incubaid.herolib.data.paramsparser { Params, parse }
|
||||||
import time
|
import time
|
||||||
|
|
||||||
totalnr := 1000000
|
totalnr := 1000000
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.radixtree
|
import incubaid.herolib.data.radixtree
|
||||||
|
|
||||||
mut rt := radixtree.new(path: '/tmp/radixtree_test', reset: true)!
|
mut rt := radixtree.new(path: '/tmp/radixtree_test', reset: true)!
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.data.resp
|
import incubaid.herolib.data.resp
|
||||||
import crypto.ed25519
|
import crypto.ed25519
|
||||||
|
|
||||||
mut b := resp.builder_new()
|
mut b := resp.builder_new()
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user