add dry run
This commit is contained in:
parent
d81a06e97a
commit
8c3e155ca9
@ -64,6 +64,10 @@ func Fpaste(life string, lexer string, fileContent string) error {
|
|||||||
|
|
||||||
fmt.Println("Uploading...")
|
fmt.Println("Uploading...")
|
||||||
resp, err := http.PostForm(rurl.String(), form)
|
resp, err := http.PostForm(rurl.String(), form)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Could not contact fpaste endpoint (%s)\n", fpasteURL)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
// The response comes back as bytes, so we copy the response buffer into io
|
// The response comes back as bytes, so we copy the response buffer into io
|
||||||
// and string it out
|
// and string it out
|
||||||
|
@ -25,6 +25,7 @@ func runPaste(ctx *cli.Context) error {
|
|||||||
stdMethod := utility.StdInChecker()
|
stdMethod := utility.StdInChecker()
|
||||||
sysInfoMethod := ctx.Bool("sysinfo")
|
sysInfoMethod := ctx.Bool("sysinfo")
|
||||||
pasteBinGoTo := ctx.String("pastebin")
|
pasteBinGoTo := ctx.String("pastebin")
|
||||||
|
dryMode := ctx.Bool("dry")
|
||||||
|
|
||||||
// Check sysinfo is enabled and run through all the required stuff
|
// Check sysinfo is enabled and run through all the required stuff
|
||||||
if sysInfoMethod {
|
if sysInfoMethod {
|
||||||
@ -61,12 +62,16 @@ func runPaste(ctx *cli.Context) error {
|
|||||||
// Check that PasteData is text, and not binary
|
// Check that PasteData is text, and not binary
|
||||||
// fmt.Println("You cannot upload binary data.")
|
// fmt.Println("You cannot upload binary data.")
|
||||||
|
|
||||||
|
if dryMode {
|
||||||
|
fmt.Printf(PasteData)
|
||||||
|
} else {
|
||||||
switch pasteBinGoTo {
|
switch pasteBinGoTo {
|
||||||
case "rpaste":
|
case "rpaste":
|
||||||
Rpaste(ctx.String("life"), ctx.String("type"), PasteData)
|
Rpaste(ctx.String("life"), ctx.String("type"), PasteData)
|
||||||
case "fpaste":
|
case "fpaste":
|
||||||
Fpaste(ctx.String("life"), ctx.String("type"), PasteData)
|
Fpaste(ctx.String("life"), ctx.String("type"), PasteData)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ var (
|
|||||||
AppBuiltWith string
|
AppBuiltWith string
|
||||||
AppConf string
|
AppConf string
|
||||||
AppVer string
|
AppVer string
|
||||||
|
BasicDmidecode bool
|
||||||
|
DryMode bool
|
||||||
LexerType string
|
LexerType string
|
||||||
LifeTime string
|
LifeTime string
|
||||||
PasteBinService string
|
PasteBinService string
|
||||||
|
11
rpaste.go
11
rpaste.go
@ -24,6 +24,8 @@ var (
|
|||||||
// This will end up being dynamic in the future
|
// This will end up being dynamic in the future
|
||||||
DefaultPasteBin = "rpaste"
|
DefaultPasteBin = "rpaste"
|
||||||
DefaultSysInfo = false
|
DefaultSysInfo = false
|
||||||
|
DefaultDryMode = false
|
||||||
|
DefaultBasicDmidecode = false
|
||||||
ShortOption = true
|
ShortOption = true
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,10 +34,12 @@ func init() {
|
|||||||
setting.AppName = AppName
|
setting.AppName = AppName
|
||||||
setting.AppVer = Version
|
setting.AppVer = Version
|
||||||
setting.AppConf = DefaultConf
|
setting.AppConf = DefaultConf
|
||||||
|
setting.DryMode = DefaultDryMode
|
||||||
setting.LexerType = DefaultLexer
|
setting.LexerType = DefaultLexer
|
||||||
setting.LifeTime = DefaultLifeTime
|
setting.LifeTime = DefaultLifeTime
|
||||||
setting.PasteBinService = DefaultPasteBin
|
setting.PasteBinService = DefaultPasteBin
|
||||||
setting.SysInfo = DefaultSysInfo
|
setting.SysInfo = DefaultSysInfo
|
||||||
|
setting.BasicDmidecode = DefaultBasicDmidecode
|
||||||
// read config?
|
// read config?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +100,13 @@ See rpaste(1)`,
|
|||||||
Usage: "Collects general system information (disables stdin and file input)",
|
Usage: "Collects general system information (disables stdin and file input)",
|
||||||
Required: false,
|
Required: false,
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "dry",
|
||||||
|
Aliases: []string{"d"},
|
||||||
|
Value: setting.DryMode,
|
||||||
|
Usage: "Turns on dry mode, which doesn't paste the output, but shows the data to stdin",
|
||||||
|
Required: false,
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "pastebin",
|
Name: "pastebin",
|
||||||
Aliases: []string{"p"},
|
Aliases: []string{"p"},
|
||||||
|
Loading…
Reference in New Issue
Block a user