On windows display directories with forward slash and also interpret prefixes

This commit is contained in:
Harshavardhana
2015-05-22 19:33:26 -07:00
parent a2cb6eacb0
commit 5ce6cc8e37
3 changed files with 16 additions and 5 deletions
+2 -1
View File
@@ -66,7 +66,8 @@ func aliasExpand(aliasedURL string, aliases map[string]string) (newURL string, e
// if more splits found return
if len(splits) == 2 {
// remove any prefixed slashes
u, err := client.Parse(expandedURL + "/" + strings.TrimPrefix(splits[1], "/"))
trimmedURL := expandedURL + "/" + strings.TrimPrefix(strings.TrimPrefix(splits[1], "/"), "\\")
u, err := client.Parse(trimmedURL)
if err != nil {
return aliasedURL, iodine.New(errInvalidURL{url: aliasedURL}, nil)
}
+6 -1
View File
@@ -17,6 +17,7 @@
package main
import (
"runtime"
"strings"
"github.com/dustin/go-humanize"
@@ -45,7 +46,11 @@ func printContent(c *client.Content) {
return "application/octet-stream"
}()
content.Size = humanize.IBytes(uint64(c.Size))
content.Name = strings.TrimSuffix(c.Name, "/")
if runtime.GOOS == "windows" {
content.Name = strings.Replace(c.Name, "/", "\\", -1)
content.Name = strings.TrimSuffix(content.Name, "\\")
}
content.Name = strings.TrimSuffix(content.Name, "/")
content.Time = c.Time.Local().Format(printDate)
console.ContentInfo(content)
}
+8 -3
View File
@@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"os"
"runtime"
"sync"
"path/filepath"
@@ -254,7 +255,7 @@ var (
// special cases only for Content where it requires custom formatting
case themesDB[currThemeName].Time:
mutex.Lock()
c.Print(fmt.Sprintf("[%s]", a...))
c.Print(fmt.Sprintf("[%s] ", a...))
mutex.Unlock()
case themesDB[currThemeName].Size:
mutex.Lock()
@@ -301,8 +302,12 @@ var (
mutex.Unlock()
case themesDB[currThemeName].Dir:
mutex.Lock()
// ugly but its needed
c.Printf("%s/\n", a...)
switch {
case runtime.GOOS == "windows":
c.Printf("%s\\\n", a...)
default:
c.Printf("%s/\n", a...)
}
mutex.Unlock()
case themesDB[currThemeName].File:
mutex.Lock()