Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve _cs format #225

Merged
merged 2 commits into from
Oct 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'

### master (unreleased)

* Improve _cs format ([#223](https://github.com/scaleway/scaleway-cli/issues/223))
* Use `gotty-client` instead of `termjs-cli`
* Fix: bad detection of server already started when starting a server ([#224](https://github.com/scaleway/scaleway-cli/pull/224)) - [@arianvp](https://github.com/arianvp)
* Added _cs ([#180](https://github.com/scaleway/scaleway-cli/issues/180))
Expand Down
32 changes: 27 additions & 5 deletions pkg/cli/x_cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

package cli

import "fmt"
import (
"fmt"
"strconv"
"strings"
"time"

"github.com/scaleway/scaleway-cli/vendor/github.com/dustin/go-humanize"
)

var cmdCS = &Command{
Exec: runCS,
Expand Down Expand Up @@ -37,13 +44,28 @@ func runCS(cmd *Command, args []string) error {
if err != nil {
return fmt.Errorf("Unable to get your containers: %v", err)
}
printRawMode(cmd.Streams().Stdout, *containers)
for _, container := range containers.Containers {
fmt.Fprintf(cmd.Streams().Stdout, "s3://%s\n", container.Name)
}
return nil
}
datas, err := cmd.API.GetContainerDatas(args[0])
container := strings.Replace(args[0], "s3://", "", 1)
datas, err := cmd.API.GetContainerDatas(container)
if err != nil {
return fmt.Errorf("Unable to get your data from %s: %v", args[1], err)
return fmt.Errorf("Unable to get your data from %s: %v", container, err)
}
for _, data := range datas.Container {
t, err := time.Parse(time.RFC3339, data.LastModified)
if err != nil {
return err
}
year, month, day := t.Date()
hour, minute, _ := t.Clock()
size, err := strconv.Atoi(data.Size)
if err != nil {
return err
}
fmt.Fprintf(cmd.Streams().Stdout, "%-4d-%02d-%02d %02d:%02d %8s s3://%s/%s\n", year, month, day, hour, minute, humanize.Bytes(uint64(size)), container, data.Name)
}
printRawMode(cmd.Streams().Stdout, *datas)
return nil
}
2 changes: 1 addition & 1 deletion pkg/scwversion/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scwversion

var (
VERSION string
VERSION string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported var VERSION should have comment or be unexported

GITCOMMIT string
)
4 changes: 2 additions & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"strings"
"time"

"github.com/Sirupsen/logrus"
"github.com/moul/gotty-client"
"github.com/scaleway/scaleway-cli/pkg/sshcommand"
"github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
log "github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
"github.com/scaleway/scaleway-cli/vendor/github.com/moul/gotty-client"
)

// SpawnRedirection is used to redirects the fluxes
Expand Down
13 changes: 13 additions & 0 deletions vendor/github.com/Sirupsen/logrus/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 17 additions & 16 deletions vendor/github.com/Sirupsen/logrus/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions vendor/github.com/Sirupsen/logrus/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/github.com/Sirupsen/logrus/entry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions vendor/github.com/Sirupsen/logrus/entry_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/Sirupsen/logrus/exported.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/Sirupsen/logrus/logger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion vendor/github.com/Sirupsen/logrus/logrus.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/github.com/Sirupsen/logrus/text_formatter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading