CL-SDM is a library that provides utility functions and some extra batteries to Common Lisp. It is, essentially, my personal standard library of things I tend to use often. CL-SDM supports SBCL primarily, but is also intended to work in ClozureCL and Clisp.
The package is divided into a few separate sub-packages:
- :sdm: The core library functions.
- :sdm-args: Command line argument parser.
- :sdm-file: File information and pathname manipulation.
- :sdm-log: Logging facility.
- :sdm-term: ANSI terminal handling.
- :sdm-time: Date/Time Handling.
Most of the code was either designed out of need, but also occasionally to reduce typing. The library draws inspiration from Alexandria, UIOP, and the standard library in Crystal (and Ruby, by extension).
How do I get set up?
There are two external dependencies: BABEL and TRIVIAL-INDENT. Once you have these installed...
- Clone this repository locally.
- Use ASDF to load the system inside of your Lisp implementation (e.g.,
I use a slightly different style for my code.
- Keep lines 118 characters or shorter. Obviously sometimes you can't, but please try. Use 115 characters for Markdown files, though.
- New type declarations should have their names prefixed with
T/, for example,
t/uint32-vector. This is only for DEFTYPEs and DEFINE-PSEUDO-ENUMs.
- Try not to go below
(DEBUG 1)when optimizing unless it's an internal function that's been tested and is known to work well. Slime has issues showing signatures when
(DEBUG 0)is used.
The unit tests require two additional external dependencies: FLEXI-STREAMS and FiveAM. Once these are installed,
(asdf:test-system :cl-sdm) from the REPL.
This is partially just so I have a place to remember what I'm planning to do, and a record of what I've done.
- [x] XOR logic function.
- [x] Nicer constant declarations.
- [x] PARSE-INTEGER? that returns NIL instead of raising a condition when it can't parse.
- [x] Shorter type names for the common (un)signed integer types
- [x] Shorter array/vector declarations
- [x] Pseudo-enums (code is already written, just needs moving to CL-SDM and some expansion)
- [x] DEFINE-TYPED-FN ported from my CL-MeltySynth program and expanded
- [/] Support for &key, &optional, and &rest in DEFINE-TYPED-FN
- [x] Conversion to/from (un)signed integers
- [x] CLAMP macro
- [x] MAPAPPEND function
- [x] Various nice functions inspired by Crystal/Ruby for inspecting sequences.
- [x] SAMPLE function
- [x] Sequence shuffling
- [x] SHIFT functions
- [x] Generic DOSEQ macro
- [x] Equivalent of LAST for any sequence type.
- [x] SWAP function
- [x] Easier string trimming
- [x] Caseless string comparisons
- [x] CASE-like statement for strings
- [x] Easier concatenation of things to a string
- [x] Print numbers as binary sizes (KiB, MiB, etc).
- [x] String spitting
- [x] Pretty string indenting
- [x] STRING-REPLACE
- [x] STRING-STARTS-WITH and -ENDS-WITH
- [x] JOIN function for strings
- Argument Parsing
- [x] Support short (
-s) and long (
- [x] Automatic --help and --version handling
- [x] Custom help/version printing
- [x] Positional arg support
- [x] Fast parsing of arguments
- [x] Call arbitrary functions to check argument values
- [x] String arguments
- [x] Flag arguments
- [x] File arguments (like strings, but with some special handling)
- [x] Numeric arguments
- [ ] Make positional arg support optional
- [ ] Optionally allow - and -- as arguments
- [x] Support short (
- [x] Fast I/O functions for reading/writing integers in binary.
- [x] Fast I/O functions for reading/writing floats in binary.
- [x] Fast I/O functions for reading/writing strings in binary.
- [x] Conversion of strings to/from sequences of bytes.
- [x] Conversion of integers to/from sequences of bytes.
- [ ] Conversion of floats to/from sequences of bytes.
- [x] 24-bit integer support in the I/O functions
- [x] Date/Time arithmetic
- [x] Time Spans
- [ ] Support fractional seconds
- [ ] Time Span -> String conversions
- [x] Date Time -> String conversions
- Terminal Handling
- [x] Basic ANSI support for colors and cursor control
- [x] Progress bar
- [x] Support for the Terminology terminal
- [ ] Windows support
- [x] Basename
- [x] Check for existing directory
- [x] Get file size
- [x] Check if a path points to a directory or not
- [x] Get some basic info (last modified, mode, etc.)
- [x] Tag-based logging, where tags can be muffled.
- [x] Basic logger
- [x] Logger with colored output
- [ ] Multi-logger (write to a logger once, and the strings go to 1+ destinations)
- [ ] Concurrent logger
How do I contribute?
- Go to https://chiselapp.com/user/MistressRemilia/repository/cl-sdm and clone the Fossil repository.
- Create a new branch for your feature.
- Push locally to the new branch.
- Create a bundle with Fossil that contains your changes.
- Get in contact with me.
- Remilia Scarlet - creator and maintainer