Documentation
¶
Index ¶
- Constants
- func AcquireLock() (*flock.Flock, error)
- func CheckGitConfig(key string) (bool, error)
- func CreateDatabase(currentDir string, dbDriver string) error
- func CreateEnvFile(currentDir string, cfg *config.JotlConfig) error
- func DeleteJotlOnFail(currentDir string) error
- func EnsureGitignore(dir string) error
- func ExecuteCmd(name string, args []string, dir string) error
- func FindAvailablePort(startPort int) string
- func GetDevEnvironment() string
- func InitializeJotlDirectory(currentDir, dbDriver string) error
- func InstallDatabaseDrivers(dbDriver string) error
- func IsGitDirectory(dir string) bool
- func IsJotlInitialized(startDir string) bool
- func NonInteractiveCommand(use string, flagSet *pflag.FlagSet) string
- func OpenBrowser(url string)
- func ParsePort(port string) int
- func ReleaseLock(fl *flock.Flock) error
- func ServeConfig(port string) error
- func ValidateModuleName(moduleName string) bool
- type ConfigPaths
Constants ¶
const (
ProgramName = "jotl"
)
Variables ¶
This section is empty.
Functions ¶
func AcquireLock ¶
AcquireLock attempts to create and lock a session lock file
func CheckGitConfig ¶
func CreateDatabase ¶
CreateDatabase sets up the database for the jotl project based on the specified driver. For SQLite, it creates a database file in the jotl directory. For PostgreSQL, it assumes the database is managed externally and does not create any files (well except for a docker-compose.yaml).
func CreateEnvFile ¶
func CreateEnvFile(currentDir string, cfg *config.JotlConfig) error
CreateEnvFile creates a .env file with the configuration
func DeleteJotlOnFail ¶
DeleteJotlOnFail deletes the Jotl configuration directory if an error occurs.
func EnsureGitignore ¶
EnsureGitignore checks if a .gitignore file exists in the given directory, creates it if it does not exist, and ensures that the /jotl directory is ignored.
func ExecuteCmd ¶
ExecuteCmd provides a shorthand way to run a shell command
func FindAvailablePort ¶
func GetDevEnvironment ¶
func GetDevEnvironment() string
GetDevEnvironment scans the project directory to detect the language server
func InitializeJotlDirectory ¶
InitializeJotlDirectory creates the necessary directory structure and files for jotl. It creates the following structure: root directory/
└── jotl/ ├── db/ │ ├── .env │ └── jotl.db └── jotl.config.yaml
This structure is exclusive of postgres driver
func InstallDatabaseDrivers ¶
InstallDatabaseDrivers installs the specified database driver package using the `go get` command. Supported database drivers are "postgres" and "sqlite".
func IsGitDirectory ¶
IsGitDirectory checks if the given directory is a Git repository. It returns true if the directory contains a .git directory or a .git file (which can be the case for git submodules or alternative git configurations). It returns false otherwise.
func IsJotlInitialized ¶
IsJotlInitialized checks whether a jotl project has been initialized already in the directory tree. It returns true if the jotl directory and its necessary files exist.
func NonInteractiveCommand ¶
NonInteractiveCommand creates the command string from a flagSet to be used for getting the equivalent non-interactive shell command
func OpenBrowser ¶
func OpenBrowser(url string)
openBrowser attempts to open the default web browser with the given URL.
func ReleaseLock ¶
ReleaseLock releases and deletes the session lock file
func ServeConfig ¶
func ValidateModuleName ¶
ValidateModuleName checks if the provided module name is valid. A valid module name can contain alphanumeric characters, underscores, hyphens, and can be separated by dots or slashes. It returns true if it's a valid module name.
Types ¶
type ConfigPaths ¶
func GetConfigPaths ¶
func GetConfigPaths(currentDir string) ConfigPaths
GetConfigPaths returns the necessary paths for configuration