Basic TUI to add new service configuration

This commit is contained in:
Philipp Wolfer 2023-12-05 17:41:15 +01:00
parent ce5cdceb1f
commit ae5f1c5f26
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
8 changed files with 242 additions and 2 deletions

View file

@ -16,9 +16,11 @@ Scotty. If not, see <https://www.gnu.org/licenses/>.
package config
import (
"fmt"
"os"
"path"
"path/filepath"
"regexp"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -74,6 +76,17 @@ func DatabasePath() string {
return filepath.Join(getConfigDir(), path)
}
func ValidateKey(key string) error {
found, err := regexp.MatchString("^[A-Za-z0-9_-]+$", key)
if err != nil {
return err
} else if found {
return nil
} else {
return fmt.Errorf("key must only consist of A-Za-z0-9_-")
}
}
func setDefaults() {
viper.SetDefault("database", defaultDatabase)
viper.SetDefault("oauth-host", defaultOAuthHost)