Documentation ¶
Overview ¶
Common library for plugins and sky-cli core. Most nessary part of this package is common interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandArg ¶
type CommandArg struct { // Desrcribes type of argument or flag. // // If it should be gotten from user, use FromUser struct. // // If if user can choose if arg needed, use FromUserBool struct. // // If you want to use predefined value use FromPlugin struct Source source // Name of argument or flag. You can keep it empty with FromPlugin source Name string // Value of argument or flag. You shuold define this field only with FromPlugin source. // In other cases value will be overwritten by user's value Value string }
Describe argument or flag
type File ¶
type File struct { // if file is optional core will ask user if it's needed. Like "is {{ FileName }} needed? [Y/n]" // // if file is not optional core will ask only UserValues IsOptional bool // Nessary template values. They must be defined in plugin RequiredValues map[string]string // Values defined by user. Core will iterate over this map and ask user for it. // Example: "Enter {{ UserValue.Key }}: ". // // Keep values empty if plugin. If will be replaced UserValues map[string]string // File template // Template values as map[ValueName]Value. In template it's {{.ValueName}} Tpl string }
Contains file template and it's values
type Folder ¶
type Folder struct { // if folder is optional core will ask user if it's needed. Like "is {{ FolderName }} needed? [Y/n]" // if user doesn't need this folder, any files and folders in this folder will be ignored IsOptional bool // Contains files and folders FolderStructure }
JSON-like virtual project structure and IsOptional filed Must contain ONLY files and folders defined in this file. Any other files and folders will raise os.Exit(1)
func (*Folder) Gen ¶
func (f *Folder) Gen(pth string, askIfNeeded func(optionName string) bool, getUserFileConf func(filename string, userValues map[string]string) map[string]string, )
Generate project structure: create files and folders
This func will recursively go around all defined files and folders. For folders it will create folder and call Gen(). For files it will get user values with given func, render template and write it to file
type FolderStructure ¶
type FolderStructure map[string]interface{}
JSON-like virtual project structure.
type FromPlugin ¶ added in v0.2.0
type FromPlugin struct{}
used if you don'n want to ask user value
example: init (for go mod <init> command)
func (FromPlugin) Get ¶ added in v0.2.0
func (FromPlugin) Get() string
type FromUser ¶ added in v0.2.0
type FromUser struct{}
used if you need to get value from user
example: enter plugin url: <user input>
type FromUserBool ¶ added in v0.2.0
type FromUserBool struct{}
used if you want to ask user if this flug needed
example: -l needed for command 'ls' Y/n
func (FromUserBool) Get ¶ added in v0.2.0
func (FromUserBool) Get() string
type OsCommand ¶
type OsCommand struct { // Name of command like go, poetry, npm, etc Name string // Args and flags of command. Flugs will be applied in same order Args []CommandArg }
Describe os command. Core will execute this command before project generation
type PluginConfiger ¶
type PluginConfiger interface { // Return os commands that will be used in project. // This commands will be executed before generation. // It may be something like: "go mod init", "poetry init", etc GetOsCommands() []OsCommand // Return JSON-like virtual file system GetVirtualFs() *Folder }
Describe generating project structure