From bd05d482e24eb87b3cc5ff710f2c21c799bf694f Mon Sep 17 00:00:00 2001 From: bth Date: Mon, 19 Jan 2026 08:06:04 -0800 Subject: [PATCH] docs --- next/last.go | 5 ++++- next/next.go | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/next/last.go b/next/last.go index a6a4293..c3c29e8 100644 --- a/next/last.go +++ b/next/last.go @@ -9,12 +9,15 @@ import ( ) const ( - LS_CMD = `ls -r [0-9]*.md` + // NOTE: the -r flag: + LS_CMD = `ls -r [0-9]*.md` + // we only care about the number group: FILE_REGEXP = `(?m)^([0-9]+)\.[[:alpha:]]*\.*md$` ) var fileRegexp *regexp.Regexp = regexp.MustCompile(FILE_REGEXP) +// calls ls to get the lexical last file func last() (string, error) { // NOTE: globbing requires invoking the shell as cmd: cmd := exec.Command("sh", "-c", LS_CMD) diff --git a/next/next.go b/next/next.go index a978075..ebf1c53 100644 --- a/next/next.go +++ b/next/next.go @@ -41,7 +41,9 @@ func parseArgs(args []string) options { return opts } -func parseFile(last string) (string, error) { +// takes the complete last file string +// returns the number as string +func numFromLast(last string) (string, error) { res := fileRegexp.FindStringSubmatch(last) num := "" if len(res) < 2 { @@ -51,8 +53,10 @@ func parseFile(last string) (string, error) { return num, nil } +// takes the complete last file string and new descriptor +// returns the complete next file string func next(last string, desc string) (string, error) { - num, err := parseFile(last) + num, err := numFromLast(last) if err != nil { return "", err }