-
Notifications
You must be signed in to change notification settings - Fork 10
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
Creating state module for goquery shell state (print mode, debug, etc) and implement print lines #42
Conversation
Created printmode enums and printer.go printer.go now has two different print functions (implemented lines) Created new command .mode which takes and sets current print mode for the util print switch statement Normalized some function names (lowercase since not public to other modules)
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.
My only real comment is to change the help output to line instead of lines. Otherwise it looks perfect to land.
".exit": exit, | ||
"ls": ListDirectory, | ||
"cd": ChangeDirectory, | ||
"ls": listDirectory, |
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.
My bad
} | ||
SuggestionsMap = []prompt.Suggest{ | ||
{".connect", "Connect to a host with UUID"}, | ||
{".disconnect", "Disconnect from a host with UUID"}, | ||
{".query", "Schedule a query on a host"}, | ||
{".mode", "Change print mode (json, lines, etc)"}, |
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.
line
"github.com/AbGuthrie/goquery/config" | ||
) | ||
|
||
var validModes = map[string]config.PrintMode{ |
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.
👍
} | ||
|
||
config.SetPrintMode(mode) | ||
fmt.Printf("Print mode set to '%s'.\n", modeArg) |
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.
I would mark this as debug output to more closely mirror this osqueryi implementation.
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.
In that we should change it to debug output when that is implemented
@@ -0,0 +1,41 @@ | |||
// Package config is repsonsible for setting and returning the current | |||
// state of the shell in regards to configuration flags and mode options | |||
package config |
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.
Should the current host be stored in here?
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.
Maybe not now but in the future
} | ||
// To center align keys with "=" get longest length key name | ||
keyPadding := 0 | ||
for key := range results[0] { |
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.
OOC does go have native implementations of higher order functions? This would make a good fold.
case 0: | ||
// PrettyPrintQueryResults prints a given []result map set to standard out | ||
// taking into consideration the current state.go's print mode | ||
func PrettyPrintQueryResults(results []map[string]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.
We should typedef []map[string]string
to Rows if possible. Can go do that?
|
||
// PrintMode constants enum | ||
const ( | ||
PrintJSON PrintMode = 0 |
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.
In go do constants need to be specified or will they auto assign if left out (which we should do if go supports)
Closes #41 and update #11 (print lines)