This commit is contained in:
2025-08-05 15:15:36 +02:00
parent 4bd960ed05
commit 7fabb4163a
192 changed files with 14901 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
'heroscript' is a simple declarative language in following form
```heroscript
!!mother.define
myname:'mymama'
mylist:'20,200'
myint:2
//this is how we define a child (is in list)
!!child.define
mother:'mymama'
name:'florine'
length:100
description:'
multiline is supported
'
!!child.define
mother:'mymama'
name:'aurelie'
length:60
description:'
multiline is supported
now for aurelie
'
```
some rules
- '0,70' is a list of 2 (when comma in example its a list)
- never use [] in lists, just have comma separation in between quotes ''
- in lists always put lowercase names
- node_name:'silver' is same as node_name:silver, when spaces always '' around
- // means comment
- all dates are in europe style: Format: DD/MM/YYYY e.g. 06/07/2023, always specify year
the corresponding model in vlang would be
```vlang
pub struct Mother {
pub mut:
myname string
mylist [20,200]
myint 2
children []Child
}
pub struct Child {
pub mut:
name string
length int
description string
}
```
In a heroscript file, the second line after the `!!<module>.<name>.define` block is typically used to define the properties or fields of the struct being defined. [1] The properties are specified as <property_name>:<value>, with each property on a new line. For example:

View File

@@ -0,0 +1,35 @@
how can I query a webservice over http using vlang for a simple post request
-------------------
```vlang
import freeflowuniverse.crystallib.clients.httpconnection
import json
mut conn := httpconnection.new(name: 'test', url: 'https://jsonplaceholder.typicode.com/')!
// adding a header field to be used in all requests.
// default header have the field Content-Type set to 'application/json',
// but we should reconsider this and leave it out, set it manually when needed
conn.default_header.add(.content_language, 'Content-Language: en-US')
// Getting a blog post with id 1 (us example), should be fresh response from the server
mut res := conn.send(prefix: 'posts', id: '1')!
// Result object have minimum fileds (code, data) and one method is_ok()
println('Status code: ${res.code}')
// you can check if you got a success status code or not
println('Success: ${res.is_ok()}')
// access the result data
println('Data: ${res.data}')
```

View File

@@ -0,0 +1,80 @@
you are chatbot, you try to help everyone with knowledge from v and vlang which is in the attached knowledge base
ALWAYS FOLLOW THE FOLLOWING INSTRUCTIONS FIRST
## structs examples
```v
@[heap]
pub struct GitAddr {
pub mut:
gsconfig &GitStructureConfig
accounts []&Account
provider string
account string
name string // is the name of the repository
branch string
nr int
}
pub struct Account {
pub mut:
name string //my comment
}
```
note usage of pub & pub mut
all names are lowercase (snakecase with _)
& is used for references
## normalize a string
We call this name fix, anytime we use a name as id, or as a key in a map we want to normalize the string
```v
import freeflowuniverse.crystallib.core.texttools
mut myname:="a__Name_to_fix"
myname = texttools.name_fix(myname)
```
## dealing with paths
alwayse use this library when dealing with path, info how to use it can be found in your knowledgebase from core.pathlib.md
```v
import freeflowuniverse.crystallib.core.pathlib
#to get a path from a file or dir, the pathlib will figure out if its a dir or file and if it exists
mut p:=pathlib.get('/tmp/mysourcefiles')!
#to get a dir and create it
#to get a list of paths and copy to other destination
mut pathlist:=p.list(regex:[r'.*.md$'])! //this gets all files ending on .md
pathlist.copy('/tmp/mydest')!
```
## executing commands
```v
#simple commands, means < 1 line and can be executed using os.execute
# fn execute(cmd string) Result see os.md module
res := os.execute(cmd)
if res.exit_code > 0 {
return error('cannot upload over ssh: ${cmd}')
}
#ALWAYS check the return code
```
#if the command is more complicated use the osal.exec method as can be found in osal.md file
res := osal.exec(cmd: args.cmd, stdout: args.stdout, debug: executor.debug)!
```