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 {
// Name of argument or flag. If it should be get from user, name it like "version".
// If if this arg is required, enter value like "v1.0.0"
Name string
// Is argument or flag should be gotten from user. If true, core will ask for value from user. All previously entered values will be shown
NeedGetFromUser bool
}
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 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
func (*OsCommand) ExtructArgs ¶
Return required and optional command arguments and flags
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