-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into release-1.0
- Loading branch information
Showing
6 changed files
with
399 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/BytemarkHosting/bytemark-client/lib" | ||
"github.com/urfave/cli" | ||
"os" | ||
) | ||
|
||
func init() { | ||
|
||
commands = append(commands, cli.Command{ | ||
Name: "overview", | ||
Usage: `overview of your Bytemark hosting`, | ||
UsageText: "bytemark show account [--json] [name]", | ||
Description: `This command displays an overview of the hosting you have with Bytemark. | ||
If the --json flag is specified, prints a complete overview of the account in JSON format, including all groups and their servers.`, | ||
Flags: []cli.Flag{ | ||
cli.BoolFlag{ | ||
Name: "json", | ||
Usage: "Output account details as a JSON object", | ||
}, | ||
}, | ||
Action: With(AuthProvider, func(c *Context) error { | ||
|
||
allAccs, err := global.Client.GetAccounts() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
accName := global.Config.GetIgnoreErr("account") | ||
var def *lib.Account | ||
if accName != "" { | ||
def, err = global.Client.GetAccount(accName) | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
def, err = global.Client.GetDefaultAccount() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return lib.FormatOverview(os.Stdout, allAccs, def, global.Client.GetSessionUser()) | ||
|
||
}), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package lib | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
// IsEqualString checks strings for equalities and outputs the difference between them if not. | ||
func IsEqualString(t *testing.T, expected string, actual string) { | ||
if expected == actual { | ||
return | ||
} | ||
expectedjs, err := json.Marshal(expected) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
actualjs, err := json.Marshal(actual) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
expr := []rune(expected) | ||
actr := []rune(actual) | ||
|
||
if len(expr) != len(actr) { | ||
t.Errorf("String lengths differ. expected: %d actual: %d\r\n", len(expr), len(actr)) | ||
} | ||
sz := len(expr) | ||
if len(expr) > len(actr) { | ||
sz = len(actr) | ||
} | ||
for i := 0; i < sz; i++ { | ||
if expr[i] != actr[i] { | ||
fmt.Printf("chr #%d differs. e:'%c' a:'%c'\r\n", i, expr[i], actr[i]) | ||
} | ||
} | ||
|
||
fmt.Printf("\r\n%s\r\n%s", map[string]string{"data": string(expectedjs)}, map[string]string{"data": string(actualjs)}) | ||
t.Fail() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.