mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-29 21:27:05 +02:00
Basic TUI to add new service configuration
This commit is contained in:
parent
ce5cdceb1f
commit
ae5f1c5f26
8 changed files with 242 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue