snoop

package
v0.0.0-...-5e37444 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2022 License: MIT Imports: 11 Imported by: 0

README

snoop-acme - automate your acme experience

I love tinkering with stuff, which shouldn't be a surprise given that I'm writing a bunch of tooling around acme. I'm also pretty forgetful however so I like to be able to automate as much as I can on both my work and home machines. The ability to manipulate editor state via a virtual file system is wonderful and a true joy for someone who likes to poke at stuff. It does mean that I need to remember all of the tooling that I'm writing though which is less good...

Previously I have always used Vim (I still use it as my daily driver at work to be honest) but with the workflow of living in a terminal, having a LOT of aliases, shell functions and utility scripts dotted around the place and making use of programs such as fzf and wd to help me navigate things. I'd like to be able to pull my current tooling into acme itself and get a proper workflow sorted out that lets me make the edits I need to make, manage external systems and APIs and keep track of what I am doing.

Enter acme-corp and the snooper.

The snopper is a local webserver currently. I know, I know: it would be a lot more in the spirit of things to have it mount its own 9fs file system to do all of this but I do know how to write webservers, I don't (currently) know how to get 9fs working in a nice way that doesn't require 9p to work so there's not a huge difference either way. The server comes with several utility scripts that are essentially canned requests that set state to modify some tooling I've written:

  • Enable / disable format on save for all windows.
  • Allow for canned "you X-clicked on this text in the tag" events to be injected, so that they can be bound to keys using something like shkd or my compiled in dwm config. (Indent the current paragraph, wrap lines etc...)
  • I'd really like to get a kind of vim-style ex mode with a pop up command line via a key binding. My laptops don't have decent three button mouse emulation which means modifiers and frantic swiping all over the place to get to the tag to make a simple ,x/#/ c/;;/ style comment replacement edit. When I have access to my real mouse this isn't a problem but I want to get a "run this Edit command" pop up working ASAP: a lot of my edits in vim are done using :%s/.../.../g so if I can get a replacement for that which I'm happy with I'll be a very happy Glenda.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcmeSnooper

type AcmeSnooper struct {
	// contains filtered or unexported fields
}

An AcmeSnooper snoops on acme events and listens for custom action requests over TCP. This allows for richer reuse of existing acme wrappers from acme.go

func NewAcmeSnooper

func NewAcmeSnooper(debug bool) *AcmeSnooper

NewAcmeSnooper inits an acme snooper and grabs the /+snoop window so that we can send messages back to acme in a consistent way.

func (*AcmeSnooper) Snoop

func (a *AcmeSnooper) Snoop(chSignals chan os.Signal)

Snoop kicks off our local server and starts listening in on acme events.

type FileType

type FileType struct {
	Tools []Tool
	// contains filtered or unexported fields
}

A FileType defines a set of Tools and an associated file type to run them on. If the files support a unix shebang then we try to parse that as well if the extension is missing.

func (*FileType) Matches

func (f *FileType) Matches(e *acme.LogEvent) bool

Matches checks to see if this is a file we need to reformat

func (*FileType) Reformat

func (f *FileType) Reformat(e *acme.LogEvent) string

Reformat applies all known formatters to the underlying file

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

A Listener runs the event loop that owns our TCP socket and routes incoming messages to their relevant handlers.

func NewListener

func NewListener(port int) *Listener

NewListener initialises a new Listener without any handlers

func (*Listener) HandleIncomingConnections

func (l *Listener) HandleIncomingConnections()

HandleIncomingConnections binds to a tcp socket and serves handler responses for incoming connections. Runs in a goroutine.

func (*Listener) Register

func (l *Listener) Register(route string, handler MessageHandler)

Register registers a new message handler with a given route

type Message

type Message struct {
	// contains filtered or unexported fields
}

A Message is a simple RPC message format to allow for very simple scripts that pass simple string messages to the snooper for it to process. Ideally this should be exposed as a 9fs file system in the same way as acme itself but for now this will have to do.

func NewMessage

func NewMessage(s string) (*Message, error)

NewMessage constructs a new Message from a string that we received over the network. At this stage we are not guaranteed that this message is valid, only that we were able to split it into a handler and content.

type MessageHandler

type MessageHandler func(s string) (string, error)

A MessageHandler is a function that knows how to parse a given message type

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

A Tool is a program that can rewrite source files or report on errors that were encountered in the code.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL