-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Commands Refactor Part 2 #263
Conversation
warningRebasing this on top of master once #262 lands. |
okay, this should be ready. cc @mappum @maybebtc |
thanks for the git ninja work. very much appreciated. will have a look |
This branch's
|
Yes, we definitely want help text printed out. |
res.SetError(err, cmds.ErrNormal) | ||
return | ||
} | ||
ctx.Node = node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this assignment have a side-effect?
Read further and realized the context is passed to the handler with the node in tow.
Is there a plan for removing IPFS-specific concepts from the commands.Context? Doesn't seem like this library could be extracted otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's the reason I kept all the IPFS-specific stuff contained in the Context, but I'm not sure exactly how we should do it. Maybe I should just change it to a map[string]interface{}
? Anyway, I'm not too worried about making the library vendorable right away since making it work with IPFS is higher priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree. Let's try to not introduce more ipfs specific things and vendor later
—
Sent from Mailbox
On Tue, Nov 4, 2014 at 3:30 PM, Matt Bell [email protected]
wrote:
+func daemonFunc(res cmds.Response, req cmds.Request) {
- ctx := req.Context()
- lk, err := daemon.Lock(ctx.ConfigRoot)
- if err != nil {
res.SetError(fmt.Errorf("Couldn't obtain lock. Is another daemon already running?"), cmds.ErrNormal)
return
- }
- defer lk.Close()
- node, err := core.NewIpfsNode(ctx.Config, true)
- if err != nil {
res.SetError(err, cmds.ErrNormal)
return
- }
- ctx.Node = node
Yep, that's the reason I kept all the IPFS-specific stuff contained in the Context, but I'm not sure exactly how we should do it. Maybe I should just change it to amap[string]interface{}
? Anyway, I'm not too worried about making the library vendorable right away since making it work with IPFS is higher priority.
Reply to this email directly or view it on GitHub:
https://github.com/jbenet/go-ipfs/pull/263/files#r19845198
These argument hints are quite helpful. ipfs
ipfs2
|
// log is the command logger | ||
var log = u.Logger("cmd/ipfs") | ||
|
||
func main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
@mappum @maybebtc how's it going over here? |
Other than generating the proper help text, a lot of the commands are done:
|
func createRequest(args []string) (cmds.Request, *cmds.Command) { | ||
req, root, cmd, err := cmdsCli.Parse(args, Root, commands.Root) | ||
if err != nil { | ||
fmt.Println(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mappum Is the class of errors returned by Parse designed around user readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since its input is coming from the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mappum sgtm
output := make([]Object, len(req.Arguments())) | ||
|
||
for i, arg := range req.Arguments() { | ||
path := arg.(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cast safely
Awesome! I'll CR in a bit. |
License: MIT Signed-off-by: Brian Tiger Chow <[email protected]>
License: MIT Signed-off-by: Brian Tiger Chow <[email protected]>
License: MIT Signed-off-by: Brian Tiger Chow <[email protected]>
(The file path is omitted, but since only one object can be added at a time, I think this is ok)
… argument or string argument)
…have any argument definitions
Closed in favor of #332 |
gx publish 4.4.24
We split #196 in two parts. this is the second. (#262 is the first). This builds on all the changes to commands/.