fix(cmd/diag): inorder output

License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
This commit is contained in:
Overbool 2018-10-27 00:55:03 +08:00 committed by Steven Allen
parent 35959d623b
commit d26f97a902
4 changed files with 17 additions and 9 deletions

View File

@ -1,6 +1,7 @@
package commands
import (
"bytes"
"fmt"
"io"
"sort"
@ -8,7 +9,8 @@ import (
"time"
oldcmds "github.com/ipfs/go-ipfs/commands"
cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds"
cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds"
cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
)
@ -38,7 +40,9 @@ Lists running and recently run commands.
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *[]*cmds.ReqLogEntry) error {
verbose, _ := req.Options[verboseOptionName].(bool)
tw := tabwriter.NewWriter(w, 4, 4, 2, ' ', 0)
buf := new(bytes.Buffer)
tw := tabwriter.NewWriter(buf, 4, 4, 2, ' ', 0)
if verbose {
fmt.Fprint(tw, "ID\t")
}
@ -74,9 +78,13 @@ Lists running and recently run commands.
live = req.EndTime.Sub(req.StartTime)
}
t := req.StartTime.Format(time.Stamp)
fmt.Fprintf(w, "%t\t%s\t%s\n", req.Active, t, live)
fmt.Fprintf(tw, "%t\t%s\t%s\n", req.Active, t, live)
}
return tw.Flush()
tw.Flush()
fmt.Fprint(w, buf)
return nil
}),
},
Type: []*cmds.ReqLogEntry{},

View File

@ -1,7 +1,7 @@
package commands
import (
cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds"
cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds"
cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
)

View File

@ -3,7 +3,7 @@
package commands
import (
cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds"
cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds"
cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
)

View File

@ -3,7 +3,7 @@ package commands
import (
"errors"
cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds"
cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds"
cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
)
@ -13,7 +13,7 @@ var MountCmd = &cmds.Command{
ShortDescription: "Not yet implemented on Windows. :(",
},
Run: func(req cmds.Request, res cmds.Response) {
res.SetError(errors.New("Mount isn't compatible with Windows yet"), cmdkit.ErrNormal)
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
return errors.New("Mount isn't compatible with Windows yet")
},
}