Skip to content

FirowMD/interactive_program_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Template for interactive programs, which will be written in V.

Includes a small amount of built-in features:

  • Help message printing (just help and also help <command>)
  • Aliases (for example you can use q instead of quit)

Command creating

To create a new command follow the steps:

  1. Create structure based on Command interface like existing one:
struct CommandEcho {
mut:
	name string = 'echo'
	description string = 'Prints the given text to the console.'
	aliases []string
	cmdhandler &CommandHandler
}
  1. Add print_help and run functions to your structure

  2. Add created structure to CommandHandler (init function):

fn (mut c CommandHandler) init() {
	// Put new commands here
	c.add_command(CommandEcho{ cmdhandler: &c })
	c.add_command(CommandQuit{ cmdhandler: &c })
	c.add_command(CommandHelp{ cmdhandler: &c })
}

About

Template for interactive program

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages