Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f39864c
Moved most view properties to the top, leaving Layout function much s…
pwolowiec Feb 16, 2017
738ac53
Merge branch 'master' of https://github.com/asciimoo/wuzz into refactor
pwolowiec Feb 16, 2017
54ef832
[fix] disable wrapping of editable views - related to #61
asciimoo Feb 16, 2017
f131e1a
Moved most view properties to the top, leaving Layout function much s…
pwolowiec Feb 16, 2017
25cc9ad
Merge branch 'master' into refactor
pwolowiec Feb 16, 2017
221de5a
run gofmt
pwolowiec Feb 17, 2017
352a9df
Moved most view properties to the top, leaving Layout function much s…
pwolowiec Feb 16, 2017
112e85f
[fix] disable wrapping of editable views - related to #61
asciimoo Feb 16, 2017
fa40a8d
Moved most view properties to the top, leaving Layout function much s…
pwolowiec Feb 16, 2017
2c20c95
Merge remote-tracking branch 'origin/refactor' into refactor
pwolowiec Feb 19, 2017
06dbce4
Fixed error that unabled editing URL
pwolowiec Feb 19, 2017
66143b9
Refactored SubmitRequest() function
pwolowiec Feb 20, 2017
738df99
Refactored SubmitRequest() function
pwolowiec Feb 20, 2017
12a7b51
Refactored PrintBody() function
pwolowiec Feb 20, 2017
f1d7f04
Added response info view that displays errors or response time
pwolowiec Feb 20, 2017
b73f898
Very minor typos fix (so that IDE doesn't bug me about those)
pwolowiec Feb 20, 2017
fa7124c
Refactored editors
pwolowiec Feb 21, 2017
d075c00
Moved editors to separate file
pwolowiec Feb 21, 2017
0cf3fd9
Various minor refactorings
pwolowiec Feb 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions config/helpText.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package config

var HelpText = `wuzz - Interactive cli tool for HTTP inspection

Usage: wuzz [-H|--header HEADER]... [-d|--data|--data-binary DATA] [-X|--request METHOD] [-t|--timeout MSECS] [URL]

Other command line options:
-c, --config PATH Specify custom configuration file
-h, --help Show this
-v, --version Display version number

Key bindings:
ctrl+r Send request
ctrl+s Save response
tab, ctrl+j Next window
shift+tab, ctrl+k Previous window
ctrl+h, alt+h Show history
pageUp Scroll up the current window
pageDown Scroll down the current window`
97 changes: 97 additions & 0 deletions editors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package main

import (
"github.com/jroimartin/gocui"
)

// Acts as an editor but does nothing
type EmptyEditor struct {
// Deliberately left empty
}

func (e EmptyEditor) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
// Deliberately left empty
}

// Handles BackTab (\033[Z) sequence
type BackTabEditor struct {
editor gocui.Editor
goBack func()
waitingForSecondBackTabRune bool
}

func (e *BackTabEditor) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
if e.waitingForSecondBackTabRune {
if ch == 'Z' {
e.goBack()
e.waitingForSecondBackTabRune = false
return
} else {
e.editor.Edit(v, 0, '[', gocui.ModAlt)
}
}

if ch == '[' && mod == gocui.ModAlt {
e.waitingForSecondBackTabRune = true
} else {
e.editor.Edit(v, key, ch, mod)
}
}

// Calls search function
type SearchEditor struct {
editor gocui.Editor
search func()
}

func (e SearchEditor) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
e.editor.Edit(v, key, ch, mod)
e.search()
}

// Adds home and end buttons functionality
type HomeEndEditor struct {
editor gocui.Editor
}

func (e HomeEndEditor) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
switch key {
case gocui.KeyHome:
v.SetCursor(0, 0)
case gocui.KeyEnd:
v.SetCursor(len(v.Buffer())-1, 0)
default:
e.editor.Edit(v, key, ch, mod)
}
}

// Removes multi lines capabilities
type SingleLineEditor struct {
editor gocui.Editor
}

func (e SingleLineEditor) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
switch {
case (ch != 0 || key == gocui.KeySpace) && mod == 0:
e.editor.Edit(v, key, ch, mod)
// At the end of the line the default gocui editor adds a whitespace
// Force him to remove
o, _ := v.Cursor()
if o > 1 && o >= len(v.Buffer())-2 {
v.EditDelete(false)
}
return
case key == gocui.KeyArrowUp:
key = gocui.KeyHome
case key == gocui.KeyArrowDown:
key = gocui.KeyEnd
case key == gocui.KeyEnter:
return
case key == gocui.KeyArrowRight:
if x, _ := v.Cursor(); x > len(v.Buffer()) {
return
}
}

e.editor.Edit(v, key, ch, mod)
}
Loading