Skip to content

Commit

Permalink
refactor(post.go): add the viper support for the command
Browse files Browse the repository at this point in the history
  • Loading branch information
TeoDev1611 committed May 31, 2021
1 parent 3d25216 commit 41d5e05
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.
package cmd

import (
"github.com/Moldy-Community/moldy/core/packages"
"github.com/Moldy-Community/moldy/utils/colors"
"github.com/Moldy-Community/moldy/utils/functions/packages"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/Moldy-Community/moldy/utils/functions/packages"
"github.com/Moldy-Community/moldy/core/packages"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion core/config/configFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
/* Add the default values, paths, aliases and config name and type */
var (
defaults = map[string]interface{}{
"moldyPackages": map[string]string{
"moldyPackageInfo": map[string]string{
"name": "none",
"version": "none",
"author": "Example Author",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion utils/functions/packages/get.go → core/packages/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GetId(id string) (getOne, error) {
}

if dataStruct.Error {
return dataStruct, errors.New("Not data found")
return dataStruct, errors.New("not data found")
}

return dataStruct, nil
Expand Down
File renamed without changes.
16 changes: 9 additions & 7 deletions utils/functions/packages/post.go → core/packages/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ import (
"github.com/Moldy-Community/moldy/utils/colors"
"github.com/Moldy-Community/moldy/utils/functions"
"github.com/go-resty/resty/v2"
"github.com/spf13/viper"
)

func Create() (getOne, error) {
var dataStruct getOne
name := terminal.BasicPrompt("Name", "")
author := terminal.BasicPrompt("Author", "")
url := terminal.BasicPrompt("URL", "")
description := terminal.BasicPrompt("Description", "")
version := terminal.BasicPrompt("Version", "")
password := terminal.PasswordPrompt("Password")
name := viper.GetString("moldyPackageInfo.name")
author := viper.GetString("moldyPackageInfo.author")
url := viper.GetString("moldyPackageInfo.url")
description := viper.GetString("moldyPackageInfo.description")
version := viper.GetString("moldyPackageInfo.version")
colors.Info("All information successfully obtained from MoldyFile.toml")
password := terminal.PasswordPrompt("Password for the package save in a safe place")

if name == "" || author == "" || url == "" || description == "" || version == "" || password == "" {
colors.Warn("Fill all blanks")
return dataStruct, errors.New("Fill all blanks")
return dataStruct, errors.New("fill all blanks")
}

client := resty.New()
Expand Down
2 changes: 1 addition & 1 deletion utils/functions/packages/put.go → core/packages/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Update(id string) (getOne, error) {

if name == "" || author == "" || url == "" || description == "" || version == "" || password == "" || newPassword == "" {
colors.Warn("Fill all blanks")
return dataStruct, errors.New("Fill all blanks")
return dataStruct, errors.New("fill all blanks")
}

client := resty.New()
Expand Down

0 comments on commit 41d5e05

Please sign in to comment.