Skip to content

Commit

Permalink
Introduce tabs
Browse files Browse the repository at this point in the history
Allow multiple configurations file and introduce tabs to switch between
config files by introducing tabs into the terminal user interface.
  • Loading branch information
grisu48 committed Dec 17, 2024
1 parent 4f65f2d commit c3ce5d5
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 254 deletions.
14 changes: 12 additions & 2 deletions cmd/openqa-revtui/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Group struct {

/* Program configuration parameters */
type Config struct {
Name string // Configuration name, if set
Instance string // Instance URL to be used
RabbitMQ string // RabbitMQ url to be used
RabbitMQTopic string // Topic to subscribe to
Expand All @@ -29,7 +30,12 @@ type Config struct {
RequestJobLimit int // Maximum number of jobs in a single request
}

var cf Config
func (cf Config) Validate() error {
if len(cf.Groups) == 0 {
return fmt.Errorf("no review groups defined")
}
return nil
}

func (cf *Config) LoadToml(filename string) error {
if _, err := toml.DecodeFile(filename, cf); err != nil {
Expand All @@ -54,7 +60,11 @@ func (cf *Config) LoadToml(filename string) error {
}
cf.Groups[i] = group
}
return nil
// Apply filename as name, if no name is set
if cf.Name == "" {
cf.Name = extractFilename(filename)
}
return cf.Validate()
}

/* Create configuration instance and set default vaules */
Expand Down
Loading

0 comments on commit c3ce5d5

Please sign in to comment.