mirror of
https://github.com/mustbeperfect/definitive-opensource.git
synced 2026-04-18 23:54:11 +02:00
Populated CLI with initial GO
This commit is contained in:
48
cli/new/add.go
Normal file
48
cli/new/add.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"definitive-opensource/data"
|
||||
"definitive-opensource/models"
|
||||
)
|
||||
|
||||
func AddProject() error {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
|
||||
fmt.Print("GitHub repo URL: ")
|
||||
scanner.Scan()
|
||||
repo := strings.TrimSpace(scanner.Text())
|
||||
|
||||
fmt.Print("Project name: ")
|
||||
scanner.Scan()
|
||||
name := strings.TrimSpace(scanner.Text())
|
||||
|
||||
category, err := selectCategory(scanner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
platforms, err := selectPlatforms(scanner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tags, err := selectTags(scanner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
entry := models.Application{
|
||||
Name: name,
|
||||
RepoURL: repo,
|
||||
Category: category,
|
||||
Platforms: platforms,
|
||||
Tags: tags,
|
||||
}
|
||||
|
||||
return data.AppendApplication(entry)
|
||||
}
|
||||
Reference in New Issue
Block a user