Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gocloudcoder committed May 20, 2021
1 parent 58aadc5 commit 91ccfec
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 224 deletions.
13 changes: 0 additions & 13 deletions bug.md

This file was deleted.

21 changes: 3 additions & 18 deletions cmd/account.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
Expand All @@ -30,7 +15,7 @@ var (
var accountCmd = &cobra.Command{
Use: "account [<AccessKey> <SecretKey> <Bucket>]",
Short: "get/set account information",
Long: `Get/Set AccessKey and SecretKey and Bucket`,
Long: `Get/Set AccessKey and SecretKey and Bucket`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 && len(args) != 3 {
return fmt.Errorf("command account receives zero or four args, received %d\n", len(args))
Expand Down Expand Up @@ -64,7 +49,7 @@ func Account(cmd *cobra.Command, params []string) {
bucket := viper.GetString("bucket")
fmt.Println(ak)
if len(params) == 0 {
if ak== "" || sk== "" || bucket == "" {
if ak == "" || sk == "" || bucket == "" {
fmt.Println("please set your ak, sk, bucket in config file(default is ~/.qn.toml)")
} else {
fmt.Println("Reading from ~/.qn.toml....")
Expand All @@ -80,7 +65,7 @@ func Account(cmd *cobra.Command, params []string) {
if err != nil {
fmt.Println("write config failed: ", err)
}
welcome()
welcome()
} else if len(params) == 3 && !accountOver {
fmt.Println("please use -w flags. For example, qn account -w ak sk bucket")
}
Expand Down
75 changes: 0 additions & 75 deletions cmd/fetch.go

This file was deleted.

30 changes: 2 additions & 28 deletions cmd/ls.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"fmt"
"strings"

"github.com/qiniu/api.v7/v7/auth/qbox"
"github.com/qiniu/api.v7/v7/storage"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"strings"
)

type FileInfo struct {
filename string

size string

putTime string
}

Expand Down Expand Up @@ -80,14 +64,4 @@ func ls(cmd *cobra.Command, params []string) {

func init() {
rootCmd.AddCommand(lsCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// lsCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// lsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
28 changes: 6 additions & 22 deletions cmd/put.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
Expand All @@ -35,18 +20,18 @@ type PutRet struct {
Hash string `json:"hash"`
PersistentID string `json:"persistentId"`
Key string `json:"key"`
Fsize int `json:"fsize"`
Fsize int `json:"fsize"`
}

// putCmd represents the put command
var putCmd = &cobra.Command{
Use: "put <local/remote file> [<local/remote file>] [flags]",
Short: "put file to qiniu server",
Long: `use put command, you can put your local file to qiniu server, and get a url.`,
Run: put,
Long: `use put command, you can put your local file to qiniu server, and get a url.`,
Run: put,
}

func put(cmd *cobra.Command, params []string){
func put(cmd *cobra.Command, params []string) {
if len(params) <= 0 {
fmt.Println("please set filepath...")
os.Exit(0)
Expand All @@ -62,7 +47,7 @@ func put(cmd *cobra.Command, params []string){

mac := qbox.NewMac(accessKey, secretKey)
cfg := storage.Config{
ApiHost:"http://api.qiniu.com",
ApiHost: "http://api.qiniu.com",
}

for _, path := range params {
Expand All @@ -74,7 +59,6 @@ func put(cmd *cobra.Command, params []string){
}
}


func isRemoteFile(path string) bool {
return strings.HasPrefix(path, "http")
}
Expand Down Expand Up @@ -118,7 +102,7 @@ func putLocalFile(path string, mac *qbox.Mac, bucket string, cfg storage.Config)
fmt.Println("err")
}
} else {
err := os.Chdir(path[0:index+1])
err := os.Chdir(path[0 : index+1])
path = upload
if err != nil {
fmt.Println("err")
Expand Down
50 changes: 0 additions & 50 deletions cmd/rm.go

This file was deleted.

23 changes: 5 additions & 18 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
/*
Copyright © 2020 nj-jay
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"fmt"
"log"
"os"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"log"
"os"
)

var cfgFile string

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "qn",
Short: "simple qiniu-cli",
Long: `qiniu-cli is based on qiniu product about go sdk, I just simplify it in order to use it easily`,
Long: `qiniu-cli is based on qiniu product about go sdk, I just simplify it in order to use it easily`,
}

func Execute() {
Expand Down

0 comments on commit 91ccfec

Please sign in to comment.