Skip to content

Commit 7fe8541

Browse files
authored
Merge pull request #3 from HappyTobi/fix_bugs
Update some small stuff
2 parents ac97a51 + 8c964e0 commit 7fe8541

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The cli tool brings the http api to the terminal.
88
| Command | Description |
99
| --- | --- |
1010
| `warp info` | Get information about the warp charger |
11-
| `warp info version` | Get the version of the warp charger |
11+
| `warp info version warp` | Get the version of the warp charger |
1212
| `warp info version update` | Check if an warp charger update is available |
1313
| `warp info name` | Get the name of the warp charger |
1414
| `warp infor display-name` | Get the display name of the warp charger |

cmd/info.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,27 @@ func InfoCmd() *cobra.Command {
2222

2323
func versionCmd() *cobra.Command {
2424
version := &cobra.Command{
25-
Use: "version",
26-
Short: "Print Warp Charger version",
27-
RunE: info.Version,
28-
PreRunE: ValidateOutputformat,
25+
Use: "version",
26+
Short: "Show Warp Charger version or check for updates",
27+
Long: "Show Warp Charger version that is currently installed at the Warp Charger. The other option is to check for an update",
2928
}
3029

3130
version.AddCommand(updateCmd())
31+
version.AddCommand(warpmVersionCmd())
3232

3333
return version
3434
}
3535

36+
func warpmVersionCmd() *cobra.Command {
37+
warpVersion := &cobra.Command{
38+
Use: "warp",
39+
Short: "Print Warp Charger version",
40+
RunE: info.Version,
41+
PreRunE: ValidateOutputformat,
42+
}
43+
return warpVersion
44+
}
45+
3646
func updateCmd() *cobra.Command {
3747
return &cobra.Command{
3848
Use: "update",

cmd/root.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import (
1010
"github.com/spf13/viper"
1111
)
1212

13+
const (
14+
oldConfig = ".warp.yaml"
15+
configFileName = "warp.yaml"
16+
)
17+
1318
func Root() *cobra.Command {
1419
root := &cobra.Command{
1520
Use: "warp",
@@ -41,16 +46,18 @@ func initConfig() {
4146
cobra.CheckErr(err)
4247

4348
configPath := filepath.Join(home, ".config", "warp")
49+
configFilePath := filepath.Join(configPath, configFileName)
50+
configFilePathLegacy := filepath.Join(home, oldConfig)
4451

4552
migrated := false
46-
if _, err := os.Stat(filepath.Join(home, ".warp.yaml")); !os.IsNotExist(err) {
53+
if _, err := os.Stat(configFilePathLegacy); !os.IsNotExist(err) {
4754
fmt.Println("Configurations file will me moved and updated to new format")
4855
_ = os.MkdirAll(configPath, os.ModePerm)
49-
if err := os.Rename(filepath.Join(home, "warp.yaml"), filepath.Join(configPath, "warp.yaml")); err != nil {
56+
if err := os.Rename(configFilePathLegacy, configFilePath); err != nil {
5057
fmt.Println("Error while moving config file")
5158
os.Exit(1)
5259
}
53-
os.Remove(filepath.Join(home, ".warp.yaml"))
60+
os.Remove(configFilePathLegacy)
5461
migrated = true
5562
}
5663

@@ -86,6 +93,10 @@ func initConfig() {
8693
os.Exit(1)
8794
}
8895

96+
if _, err := os.Stat(configFilePath); os.IsNotExist(err) {
97+
os.WriteFile(configFilePath, []byte{}, 0644)
98+
}
99+
89100
if err := viper.WriteConfig(); err != nil {
90101
fmt.Print(err)
91102
os.Exit(1)

pkg/internal/renderer/pdf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (pR *pdfRenderer) Render(filepath string, render func(timeZone *time.Locati
8282

8383
pdf.Row(5, func() {
8484
pdf.Col(4, func() {
85-
pdf.Text(fmt.Sprintf("%s %s", pR.settings.Settings.Postcode, pR.settings.Settings.Street), props.Text{
85+
pdf.Text(fmt.Sprintf("%s %s", pR.settings.Settings.Postcode, pR.settings.Settings.City), props.Text{
8686
Align: consts.Left,
8787
})
8888
})

0 commit comments

Comments
 (0)