Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Dec 5, 2023
1 parent bd1d3ef commit 05cfaf0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 29 deletions.
18 changes: 3 additions & 15 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,11 @@ func printCompletion() int {

switch options.GetS(OPT_COMPLETION) {
case "bash":
fmt.Printf(bash.Generate(info, APP))
fmt.Print(bash.Generate(info, APP))
case "fish":
fmt.Printf(fish.Generate(info, APP))
fmt.Print(fish.Generate(info, APP))
case "zsh":
fmt.Printf(zsh.Generate(info, optMap, APP))
fmt.Print(zsh.Generate(info, optMap, APP))
default:
return 1
}
Expand All @@ -571,18 +571,6 @@ func printMan() {
)
}

// genMan generates man page
func genMan() int {
fmt.Println(
man.Generate(
genUsage(),
genAbout(""),
),
)

return 0
}

// genUsage generates usage info
func genUsage() *usage.Info {
info := usage.NewInfo()
Expand Down
6 changes: 0 additions & 6 deletions cli/cmd_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,3 @@ func getMainPackageFromBundle(bundle repo.PackageBundle) *repo.Package {

return nil
}

// printEmptyFoundPackageList prints empty packages listing
func printEmptyFoundPackageList(r *repo.SubRepository) {
fmtutil.Separator(true, strings.ToUpper(r.Name))
fmtc.Println("\n{s-}-- no packages --{!}\n")
}
5 changes: 2 additions & 3 deletions cli/cmd_gen_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package cli
// ////////////////////////////////////////////////////////////////////////////////// //

import (
"io/ioutil"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -130,15 +129,15 @@ func generateKeys(name, email string, password *secstr.String, outputPubKeyFile
return false
}

err = ioutil.WriteFile(outputPrivKeyFile, privKeyData, 0600)
err = os.WriteFile(outputPrivKeyFile, privKeyData, 0600)

if err != nil {
spinner.Update("Can't save private key: %v", err)
spinner.Done(false)
return false
}

err = ioutil.WriteFile(outputPubKeyFile, pubKeyData, 0644)
err = os.WriteFile(outputPubKeyFile, pubKeyData, 0644)

if err != nil {
spinner.Update("Can't save public key: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (c *commandHelp) Options() {
continue
}

option.Render()
option.Print()
}

fmtc.NewLine()
Expand Down Expand Up @@ -210,7 +210,7 @@ func helpAll() {
continue
}

c.Render()
c.Print()
}

fmtc.NewLine()
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd_resign.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ how many packages you have and how big they are).`)

// resignAllPackages re-singes all packages in testing and release repositories
func resignAllPackages(ctx *context, key *sign.Key) bool {
var isResigned bool
isResigned := false

if !resignRepoPackages(ctx, key, ctx.Repo.Testing) {
ctx.Logger.Get(data.REPO_TESTING).Print("Packages re-signing finished with error")
Expand Down
3 changes: 1 addition & 2 deletions cli/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ func getRepoContext(repoCfg *knf.Config) (*context, error) {

// getRepoStorage configures repository storage
func getRepoStorage(typ string, repoCfg *knf.Config) (storage.Storage, error) {
switch typ {
case storage.TYPE_FS:
if typ == storage.TYPE_FS {
return getRepoFSStorage(repoCfg)
}

Expand Down

0 comments on commit 05cfaf0

Please sign in to comment.