Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
091f6f85
Commit
091f6f85
authored
Oct 05, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added getConfig
parent
a2c2c487
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+22
-10
No files found.
cmd/ipfs/ipfs.go
View file @
091f6f85
package
main
package
main
import
(
import
(
"errors"
"fmt"
"fmt"
"os"
"os"
"runtime/pprof"
"runtime/pprof"
...
@@ -106,17 +105,30 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) {
...
@@ -106,17 +105,30 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) {
// Gets the config "-c" flag from the command, or returns
// Gets the config "-c" flag from the command, or returns
// the default configuration root directory
// the default configuration root directory
func
getConfigDir
(
c
*
commander
.
Command
)
(
string
,
error
)
{
func
getConfigDir
(
c
*
commander
.
Command
)
(
string
,
error
)
{
conf
:=
c
.
Flag
.
Lookup
(
"c"
)
.
Value
.
Get
()
if
conf
==
nil
{
// use the root cmd (that's where config is specified)
return
config
.
PathRoot
()
for
;
c
.
Parent
!=
nil
;
c
=
c
.
Parent
{
}
// flag should be defined on root.
param
:=
c
.
Flag
.
Lookup
(
"c"
)
.
Value
.
Get
()
.
(
string
)
if
param
!=
""
{
return
u
.
TildeExpansion
(
param
)
}
}
confStr
,
ok
:=
conf
.
(
string
)
if
!
ok
{
return
config
.
PathRoot
()
return
""
,
errors
.
New
(
"failed to retrieve config flag value."
)
}
func
getConfig
(
c
*
commander
.
Command
)
(
*
config
.
Config
,
error
)
{
confdir
,
err
:=
getConfigDir
(
c
)
if
err
!=
nil
{
return
nil
,
err
}
}
if
len
(
confStr
)
==
0
{
return
config
.
PathRoot
()
filename
,
err
:=
config
.
Filename
(
confdir
)
if
err
!=
nil
{
return
nil
,
err
}
}
return
u
.
TildeExpansion
(
confStr
)
return
config
.
Load
(
filename
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment