Merge branch 'development' into development_fix_hero_and_ci
* development: ... # Conflicts: # lib/core/herocmds/docusaurus.v # lib/data/encoderhero/decoder.v # lib/data/encoderhero/postgres_client_decoder_test.v # lib/web/site/play.v
This commit is contained in:
@@ -19,12 +19,12 @@ fn decode_struct[T](_ T, data string) !T {
|
||||
mut typ := T{}
|
||||
// println(data)
|
||||
$if T is $struct {
|
||||
obj_name := texttools.snake_case(T.name.all_after_last('.'))
|
||||
mut action_name := 'define.${obj_name}'
|
||||
obj_name := T.name.all_after_last('.').to_lower()
|
||||
mut action_name := '${obj_name}.define'
|
||||
if !data.contains(action_name) {
|
||||
action_name = 'configure.${obj_name}'
|
||||
action_name = '${obj_name}.configure'
|
||||
if !data.contains(action_name) {
|
||||
return error('Data does not contain action name: define.${obj_name} or ${action_name}')
|
||||
return error('Data does not contain action name: ${obj_name}.define or ${action_name}')
|
||||
}
|
||||
}
|
||||
actions_split := data.split('!!')
|
||||
|
||||
@@ -118,7 +118,7 @@ pub fn (mut e Encoder) encode_struct[T](t T) ! {
|
||||
mut mytype := reflection.type_of[T](t)
|
||||
struct_attrs := attrs_get_reflection(mytype)
|
||||
|
||||
mut action_name := texttools.snake_case(T.name.all_after_last('.'))
|
||||
mut action_name := T.name.all_after_last('.').to_lower()
|
||||
// println('action_name: ${action_name} ${T.name}')
|
||||
if 'alias' in struct_attrs {
|
||||
action_name = struct_attrs['alias'].to_lower()
|
||||
|
||||
@@ -10,12 +10,12 @@ pub mut:
|
||||
dbname string = 'postgres'
|
||||
}
|
||||
|
||||
const postgres_client_blank = '!!define.postgresql_client'
|
||||
const postgres_client_full = '!!define.postgresql_client name:production user:app_user port:5433 host:db.example.com password:secret123 dbname:myapp'
|
||||
const postgres_client_partial = '!!define.postgresql_client name:dev host:localhost password:devpass'
|
||||
const postgres_client_blank = '!!postgresql_client.configure'
|
||||
const postgres_client_full = '!!postgresql_client.configure name:production user:app_user port:5433 host:db.example.com password:secret123 dbname:myapp'
|
||||
const postgres_client_partial = '!!postgresql_client.configure name:dev host:localhost password:devpass'
|
||||
|
||||
const postgres_client_complex = '
|
||||
!!define.postgresql_client name:staging user:stage_user port:5434 host:staging.db.com password:stagepass dbname:stagingdb
|
||||
!!postgresql_client.configure name:staging user:stage_user port:5434 host:staging.db.com password:stagepass dbname:stagingdb
|
||||
'
|
||||
|
||||
fn test_postgres_client_decode_blank() ! {
|
||||
@@ -136,17 +136,17 @@ const play_script = '
|
||||
# PostgresqlClient Encode/Decode Play Script
|
||||
# This script demonstrates encoding and decoding PostgresqlClient configurations
|
||||
|
||||
!!define.postgresql_client name:playground user:play_user
|
||||
port:5432
|
||||
host:localhost
|
||||
password:playpass
|
||||
!!postgresql_client.configure name:playground user:play_user
|
||||
port:5432
|
||||
host:localhost
|
||||
password:playpass
|
||||
dbname:playdb
|
||||
|
||||
# You can also use partial configurations
|
||||
!!define.postgresql_client name:quick_test host:127.0.0.1
|
||||
!!postgresql_client.configure name:quick_test host:127.0.0.1
|
||||
|
||||
# Default configuration (all defaults)
|
||||
!!define.postgresql_client
|
||||
!!postgresql_client.configure
|
||||
'
|
||||
|
||||
fn test_play_script() ! {
|
||||
@@ -158,7 +158,7 @@ fn test_play_script() ! {
|
||||
mut clients := []PostgresqlClient{}
|
||||
|
||||
for line in lines {
|
||||
if line.starts_with('!!define.postgresql_client') {
|
||||
if line.starts_with('!!postgresql_client.configure') {
|
||||
client := decode[PostgresqlClient](line)!
|
||||
clients << client
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user