@@ -43,11 +43,14 @@ import (
43
43
"gopkg.in/urfave/cli.v1"
44
44
)
45
45
46
- const clientIdentifier = "bzzd"
46
+ const (
47
+ clientIdentifier = "swarm"
48
+ versionString = "0.2"
49
+ )
47
50
48
51
var (
49
52
gitCommit string // Git SHA1 commit hash of the release (set via linker flags)
50
- app = utils .NewApp (gitCommit , "Ethereum Swarm server daemon " )
53
+ app = utils .NewApp (gitCommit , "Ethereum Swarm" )
51
54
)
52
55
53
56
var (
85
88
Usage : "URL of the Ethereum API provider" ,
86
89
Value : node .DefaultIPCEndpoint ("geth" ),
87
90
}
91
+ SwarmApiFlag = cli.StringFlag {
92
+ Name : "bzzapi" ,
93
+ Usage : "Swarm HTTP endpoint" ,
94
+ Value : "http://127.0.0.1:8500" ,
95
+ }
96
+ SwarmRecursiveUploadFlag = cli.BoolFlag {
97
+ Name : "recursive" ,
98
+ Usage : "Upload directories recursively" ,
99
+ }
100
+ SwarmWantManifestFlag = cli.BoolTFlag {
101
+ Name : "manifest" ,
102
+ Usage : "Automatic manifest upload" ,
103
+ }
88
104
)
89
105
90
106
var defaultBootnodes = []string {}
@@ -96,8 +112,39 @@ func init() {
96
112
utils .IPCApiFlag .Value = "admin, bzz, chequebook, debug, rpc, web3"
97
113
98
114
// Set up the cli app.
99
- app .Commands = nil
100
115
app .Action = bzzd
116
+ app .HideVersion = true // we have a command to print the version
117
+ app .Copyright = "Copyright 2013-2016 The go-ethereum Authors"
118
+ app .Commands = []cli.Command {
119
+ cli.Command {
120
+ Action : version ,
121
+ Name : "version" ,
122
+ Usage : "Print version numbers" ,
123
+ ArgsUsage : " " ,
124
+ Description : `
125
+ The output of this command is supposed to be machine-readable.
126
+ ` ,
127
+ },
128
+ cli.Command {
129
+ Action : upload ,
130
+ Name : "up" ,
131
+ Usage : "upload a file or directory to swarm using the HTTP API" ,
132
+ ArgsUsage : " <file>" ,
133
+ Description : `
134
+ "upload a file or directory to swarm using the HTTP API and prints the root hash",
135
+ ` ,
136
+ },
137
+ cli.Command {
138
+ Action : hash ,
139
+ Name : "hash" ,
140
+ Usage : "print the swarm hash of a file or directory" ,
141
+ ArgsUsage : " <file>" ,
142
+ Description : `
143
+ Prints the swarm hash of file or directory.
144
+ ` ,
145
+ },
146
+ }
147
+
101
148
app .Flags = []cli.Flag {
102
149
utils .IdentityFlag ,
103
150
utils .DataDirFlag ,
@@ -123,6 +170,10 @@ func init() {
123
170
SwarmAccountFlag ,
124
171
SwarmNetworkIdFlag ,
125
172
ChequebookAddrFlag ,
173
+ // upload flags
174
+ SwarmApiFlag ,
175
+ SwarmRecursiveUploadFlag ,
176
+ SwarmWantManifestFlag ,
126
177
}
127
178
app .Flags = append (app .Flags , debug .Flags ... )
128
179
app .Before = func (ctx * cli.Context ) error {
@@ -142,6 +193,20 @@ func main() {
142
193
}
143
194
}
144
195
196
+ func version (ctx * cli.Context ) error {
197
+ fmt .Println (strings .Title (clientIdentifier ))
198
+ fmt .Println ("Version:" , versionString )
199
+ if gitCommit != "" {
200
+ fmt .Println ("Git Commit:" , gitCommit )
201
+ }
202
+ fmt .Println ("Network Id:" , ctx .GlobalInt (utils .NetworkIdFlag .Name ))
203
+ fmt .Println ("Go Version:" , runtime .Version ())
204
+ fmt .Println ("OS:" , runtime .GOOS )
205
+ fmt .Printf ("GOPATH=%s\n " , os .Getenv ("GOPATH" ))
206
+ fmt .Printf ("GOROOT=%s\n " , runtime .GOROOT ())
207
+ return nil
208
+ }
209
+
145
210
func bzzd (ctx * cli.Context ) error {
146
211
stack := utils .MakeNode (ctx , clientIdentifier , gitCommit )
147
212
registerBzzService (ctx , stack )
0 commit comments