Skip to content

How to specify configuration files during compilation/runtime #23987

Discussion options

You must be logged in to vote
// [v run . -f 'etc/config_dev.toml']
pub fn config_toml() string {
	log.debug('${@METHOD}  ${@MOD}.${@FILE_LINE}')
	mut cf_toml := os.join_path('.', 'etc', 'config.toml') 
	args := os.args[1..]
	for i in 0 .. args.len {
		if args[i] == '-f' {
			if i + 1 >= args.len {
				log.error('Error:  -f  Missing file name after parameter')
			}
			cf_toml = args[i + 1]
			break
		}
	}
	log.debug('config file:' + os.join_path(os.getwd(), cf_toml))
	return cf_toml
}

Add supports Windows and MOCOS

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@jorgeluismireles
Comment options

@Avey777
Comment options

@Avey777
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Avey777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants