aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-05-16 14:09:04 -0400
committerSam Anthony <sam@samanthony.xyz>2026-05-16 14:09:04 -0400
commit5b6a50dfb8ea880c4ed77e55020dea3fd0c9a0a2 (patch)
tree9025f22f85233c09bd33fbced8ededf8652822ec /cmd
parente39f8f5b075b67ae3c63cc3ee7c5b7e81271b530 (diff)
downloadlulu-5b6a50dfb8ea880c4ed77e55020dea3fd0c9a0a2.zip
cli: rename orders->jobs, sort by timestamp
Diffstat (limited to 'cmd')
-rw-r--r--cmd/lulu/cli.go4
-rw-r--r--cmd/lulu/jobs.go (renamed from cmd/lulu/orders.go)10
2 files changed, 9 insertions, 5 deletions
diff --git a/cmd/lulu/cli.go b/cmd/lulu/cli.go
index 7a952ed..deedb92 100644
--- a/cmd/lulu/cli.go
+++ b/cmd/lulu/cli.go
@@ -26,8 +26,8 @@ type CLI struct {
ValidateCover ValidateCoverCmd `cmd name:"vc" help:"Validate cover file"`
CoverDimensions CoverDimensionsCmd `cmd name:"cd" help:"Calculate cover dimensions"`
Cost CostCmd `cmd help:"Calculate the cost of a print job"`
- Orders OrdersCmd `cmd help:"Retrieve past print jobs"`
- //TODO Info InfoCmd `cmd help:"Retrieve information about an order"`
+ Jobs JobsCmd `cmd help:"Retrieve past print jobs"`
+ //TODO Info JobCmd `cmd help:"Retrieve information about a particular print job"`
List ListCmd `cmd help:"Print a list of valid argument values"`
}
diff --git a/cmd/lulu/orders.go b/cmd/lulu/jobs.go
index bbbf465..f56c3e0 100644
--- a/cmd/lulu/orders.go
+++ b/cmd/lulu/jobs.go
@@ -3,13 +3,14 @@ package main
import (
"fmt"
"os"
+ "slices"
"text/tabwriter"
"time"
"git.samanthony.xyz/lulu"
)
-type OrdersCmd struct {
+type JobsCmd struct {
CreatedAfter time.Time `help:"Include only orders created after this *time"`
CreatedBefore time.Time `help:"Include only orders created before this *time"`
ModifiedAfter time.Time `help:"Include only orders modified after this *time"`
@@ -17,7 +18,7 @@ type OrdersCmd struct {
Status lulu.OrderStatus `help:"${order_status_help}"`
}
-func (cmd OrdersCmd) Run(clnt *lulu.Client) error {
+func (cmd JobsCmd) Run(clnt *lulu.Client) error {
jobs, err := clnt.GetPrintJobs(cmd.queries()...)
if err != nil {
return err
@@ -26,6 +27,9 @@ func (cmd OrdersCmd) Run(clnt *lulu.Client) error {
fmt.Fprintf(os.Stderr, "lulu: no orders\n")
return nil
}
+ slices.SortFunc(jobs, func(a, b lulu.PrintJob) int {
+ return a.Created.Compare(b.Created)
+ })
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.AlignRight)
fmt.Fprintf(w, "created\textid\tid\torderid\tnitems\ttotal\tstatus\t\n")
@@ -42,7 +46,7 @@ func (cmd OrdersCmd) Run(clnt *lulu.Client) error {
return w.Flush()
}
-func (cmd OrdersCmd) queries() []lulu.PrintJobQuery {
+func (cmd JobsCmd) queries() []lulu.PrintJobQuery {
var queries []lulu.PrintJobQuery
if !cmd.CreatedAfter.IsZero() {
queries = append(queries, lulu.FilterCreatedAfter(cmd.CreatedAfter))