Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10494208
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/config/options.go b/config/options.go
index 1abf9ee..57f08cd 100644
--- a/config/options.go
+++ b/config/options.go
@@ -1,56 +1,71 @@
package config
import (
+ "net/url"
+
"github.com/cloudfoundry/jibber_jabber"
"github.com/writeas/writeas-cli/log"
cli "gopkg.in/urfave/cli.v1"
)
// Application constants.
const (
Version = "2.0"
defaultUserAgent = "writeas-cli v" + Version
// Defaults for posts on Write.as.
DefaultFont = PostFontMono
WriteasBaseURL = "https://write.as"
DevBaseURL = "https://development.write.as"
TorBaseURL = "http://writeas7pm7rcdqg.onion"
)
func UserAgent(c *cli.Context) string {
ua := c.String("user-agent")
if ua == "" {
return defaultUserAgent
}
return ua + " (" + defaultUserAgent + ")"
}
func IsTor(c *cli.Context) bool {
return c.Bool("tor") || c.Bool("t")
}
func Language(c *cli.Context, auto bool) string {
if l := c.String("lang"); l != "" {
return l
}
if !auto {
return ""
}
// Automatically detect language
l, err := jibber_jabber.DetectLanguage()
if err != nil {
log.Info(c, "Language detection failed: %s", err)
return ""
}
return l
}
func Collection(c *cli.Context) string {
if coll := c.String("c"); coll != "" {
return coll
}
if coll := c.String("b"); coll != "" {
return coll
}
return ""
}
+
+// HostDirectory returns the sub directory string for the host flag if set
+func HostDirectory(c *cli.Context) (string, error) {
+ if host := c.GlobalString("host"); host != "" {
+ u, err := url.Parse(host)
+ if err != nil {
+ return "", err // TODO
+ }
+ return u.Hostname(), nil
+ }
+
+ return "", nil
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Mar 6, 9:48 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3165940
Attached To
rWCLI writeas-cli
Event Timeline
Log In to Comment