refactor: Dynamically determine hero directory

- Get script directory to find herolib root
- Determine hero_dir based on script location
- Verify hero_dir and hero.v existence
- Print used hero directory
This commit is contained in:
Mahmoud-Emad
2025-09-29 15:03:28 +03:00
parent c26ba98884
commit bd921770fd
2 changed files with 20 additions and 2 deletions

View File

@@ -30,8 +30,23 @@ if additional_args.len > 0 {
exit(1)
}
// Change to the hero directory
hero_dir := os.join_path(os.home_dir(), 'code/github/incubaid/herolib/cli')
// Determine the hero directory dynamically
// Get the directory where this script is located
script_dir := os.dir(os.executable())
// The script is in cli/, so the herolib root is one level up
herolib_root := os.dir(script_dir)
hero_dir := os.join_path(herolib_root, 'cli')
// Verify the directory exists and contains hero.v
if !os.exists(hero_dir) {
panic('Hero CLI directory not found: ${hero_dir}')
}
hero_v_path := os.join_path(hero_dir, 'hero.v')
if !os.exists(hero_v_path) {
panic('hero.v not found in: ${hero_dir}')
}
println('Using hero directory: ${hero_dir}')
os.chdir(hero_dir) or { panic('Failed to change directory to ${hero_dir}: ${err}') }
// Set HEROPATH based on OS

View File

@@ -2,6 +2,9 @@ module openrpc
import freeflowuniverse.herolib.schemas.jsonschema { Reference, SchemaRef }
// Generic type for any value in examples
type Any = string | int | f64 | bool | map[string]Any | []Any
// This is the root object of the OpenRPC document.
// The contents of this object represent a whole OpenRPC document.
// How this object is constructed or stored is outside the scope of the OpenRPC Specification.