aboutsummaryrefslogtreecommitdiffstats
path: root/l
AgeCommit message (Collapse)Author
2021-02-03Update TODOTeddy Wing
2021-02-03parse-options: Error if no extension ID arguments were givenTeddy Wing
2021-02-03main: Replace hard-coded extension ID with list from command line argsTeddy Wing
Reload the extension IDs given on the command line now that we have them from the `config` object. Replace the hard-coded extension ID that I had been using for testing.
2021-02-03Update TODOTeddy Wing
2021-02-03main: Get WebSocket URL from command line for `*client*`Teddy Wing
Keep the `*client*` global variable, but use the client in `config`, constructed from the WebSocket URL passed from the command line. Not a huge fan of the global variable, but it's way easier to keep it like this rather than passing the client down to the `attach-to-target` and `reload-extension` functions.
2021-02-03config: Initialise a new websocket-driver client on new configTeddy Wing
Add a new `make-config` function to construct a `config` object. This creates a new websocket-driver client and stores it in the `ws-client` slot in the `config`. Before this, I thought about using a writer method on the `socket-url` slot that creates a new client. This didn't work in `make-instance` though. Perhaps there's a way to have the `:initarg` use the writer, but I'm not sure.
2021-02-03Move DevTools functions to `devtools-protocol.lisp`Teddy Wing
The `main.lisp` file was getting crowded. Move DevTools Protocol-related functions into a new file.
2021-02-03Update TODOTeddy Wing
2021-02-03parse-options: Exit with error if `--socket-url` isn't givenTeddy Wing
2021-02-03main: Move option parsing code to new function `parse-options`Teddy Wing
Make a new function `parse-options` that parses the command line options and returns a `config` object. We'll use that object instead of `options` in `main`. Cleans up the `main` function a bit. Currently, we just print the `config` object to ensure we're storing the proper values. Followed Practical Common Lisp's example to implement `print-object` so we can see the contents of its slots: http://www.gigamonkeys.com/book/practical-a-spam-filter.html#the-heart-of-a-spam-filter Still need to implement error checking for a missing `--socket-url` option.
2021-02-02Add config classTeddy Wing
We'll use this as a storage container for the command line options.
2021-02-02Update TODOTeddy Wing
2021-02-02main: Handle command line argument parsing errorsTeddy Wing
Add an error handler that just prints the error messages from 'unix-opts' to standard error and exits with EX_USAGE. Inspired by: - http://lispcookbook.github.io/cl-cookbook/scripting.html#handling-malformed-or-missing-arguments - https://github.com/libre-man/unix-opts/blob/0e61f34b2ecf62288437810d4abb31e572048b04/example/example.lisp
2021-02-02main: Show help output with -h/--helpTeddy Wing
Add `:arg-parser` to the `:socket-url` definition because 'unix-opts' requires it in order to display the "SOCKET_URL" `:meta-var` in the help output.
2021-02-02main: Start command line option parsingTeddy Wing
Include the 'unix-opts' library described in http://lispcookbook.github.io/cl-cookbook/scripting.html#parsing-command-line-arguments for command line option parsing. Define the options I need. We want a `--socket-url` option, and a list of extension IDs as free arguments. Implement the `-V` version command line argument. Thanks to JJJ (https://stackoverflow.com/users/1337941/jjj) on Stack Overflow for describing how to get the version number of an ASDF system: https://stackoverflow.com/questions/11084339/getting-the-version-of-an-asdf-system/11088022#11088022 Add a new `options.lisp` file where we'll add the option parsing restart error handling functions required by 'unix-opts'.
2021-02-01Add .gitignoreTeddy Wing
Ignore FASL files.
2021-02-01main.lisp: Update testing WebSocket URLTeddy Wing
2021-02-01Update TODOTeddy Wing
2021-02-01main: Ensure WebSocket connection is always closedTeddy Wing
Create a new `with-websocket-connection` decorator that starts and closes a WebSocket connection to the given `client` around the body forms. Thanks to Practical Common Lisp's "The Special Operators" chapter (http://www.gigamonkeys.com/book/the-special-operators.html#unwinding-the-stack) for introducing me to `unwind-protect`. Couldn't figure out how to get the new macro to auto-indent properly with Vlime, so ended up manually indenting it.
2021-02-01websocket-send: Use local `client` variable instead of globalTeddy Wing
Must have copy-pasted that s-expression from elsewhere in the file.
2021-01-31Update TODOTeddy Wing
2021-01-31Update TODOTeddy Wing
2021-01-31main: Replace `sleep` call with a `wait-group`Teddy Wing
The `sleep` call allowed me to test the behaviour of the program, since without it, it would exit before the WebSocket messages had a chance to be sent and received. But we shouldn't be waiting a fixed number of seconds for the program to execute. Instead, we should only keep the program alive as long as there are messages to be sent and received. This adds a Go-style wait group using my wait-group library that increments the wait group when we send a WebSocket message, and decrements it when we receive a WebSocket response. That allows us to keep the program alive only for the amount of time necessary for the messages to be exchanged.
2021-01-31Update TODOTeddy Wing
2021-01-31Convert `filter` from a function to a macroTeddy Wing
Doesn't make a big difference, just for fun. I like the idea of a compile-time version of this since it's essentially just renaming `remove-if-not`. Move it to a new file so we can include it before it's used in `main.lisp`.
2021-01-31Update TODOTeddy Wing
2021-01-30main.lisp: Use `find-if` in `requested-extension-p`Teddy Wing
I've been reading Practical Common Lisp's "Collections" chapter (http://www.gigamonkeys.com/book/collections.html) and it seemed like `find-if` would be nicer here than what I wrote before.
2021-01-30main.lisp: Change `filter` to use `remove-if-not`Teddy Wing
Just learned about `remove-if-not`. Really cleans up this function. Not even really necessary to keep `filter`, but I guess I'll hold on to it for now.
2021-01-30extension-targets: Use `string=` instead of `equal`Teddy Wing
Just learned that `string=` exists, and that seems to describe the intent better than `equal`.
2021-01-30Update TODOTeddy Wing
2021-01-30main.lisp: Update temporary WebSocket URLTeddy Wing
2021-01-24Add TODOTeddy Wing
2021-01-24main.lisp: Reload extensionsTeddy Wing
Send DevTools Protocol messages to reload extensions. Not easy to do things sequentially since the responses have to be handled in `ws-on-message`. Once we filter the list of extensions wanted to reload, attach to their DevTools targets, then send them JavaScript evaluation messages that tells the extensions to reload.
2021-01-24main.lisp: Rename `get-targets-msg` to `target-get-targets-msg`Teddy Wing
Prefix the function name with the name of the DevTools domain to distinguish Target message functions from Runtime functions.
2021-01-24filter: Fix `let` binding syntaxTeddy Wing
2021-01-24main.lisp: Filter DevTools targets to chosen extensionsTeddy Wing
Filter a list of extension background page targets. The extension IDs should come from the command line, but I've hard-coded the list here. Increased the `sleep` time to allow time for the messages to be sent & received before the program exits. Will need to figure out a proper way to do this later.
2021-01-24main.lisp: Parse `Target.getTargets` responseTeddy Wing
Use `jsown` to parse the response from the `Target.getTargets` message. Get a list of `targetInfos` from the response. Extracting keys from the JSON result with `jsown:val` raises an `error` exception when the key is not present. Turn the exception into `nil` with the `json-obj-get` function.
2021-01-24Build executableTeddy Wing
Build an executable binary by dumping an SBCL image, using the method described in: https://lispcookbook.github.io/cl-cookbook/scripting.html#with-asdf
2021-01-23Send `Target.getTargets` messageTeddy Wing
Add a `sleep` just in case we need that to have time to print the message. Use the `jsown` project for JSON encoding and decoding.
2021-01-23Define Lisp packageTeddy Wing
Define the package so we can define things inside it.
2021-01-23main.lisp: Update testing WebSocket URLTeddy Wing
2021-01-20Add a foundation for a Common Lisp versionTeddy Wing
Trying to see if I can write the program in Common Lisp. Learned how to set up an .asd project file and started with some websocket client code based on the example in: https://github.com/fukamachi/websocket-driver#client-side Need to work out how to set up JSON interaction.