Skip to content

implement lp/lpstat reference tools + CI integration tests#11

Draft
Abd002 wants to merge 2 commits intoOpenPrinting:mainfrom
Abd002:lp-lpstat
Draft

implement lp/lpstat reference tools + CI integration tests#11
Abd002 wants to merge 2 commits intoOpenPrinting:mainfrom
Abd002:lp-lpstat

Conversation

@Abd002
Copy link
Copy Markdown
Contributor

@Abd002 Abd002 commented Mar 2, 2026

Summary

This PR implements WoC 2026 deliverables by adding Rust reference implementations of core CUPS CLI workflows:

  • lp (job submission)
  • lpstat (status / discovery)
    …built on top of cups-rs/libcups, with CI + integration coverage.

What’s included

  • examples/lp.rs: simplified lp workflow (destination/default, files + stdin, basic options).
  • examples/lpstat.rs: simplified lpstat workflow (common query flags).
  • .github/workflows/rust.yml: CI GitHub Actions workflow that runs unit tests + CUPS integration checks.
  • tests/test_lp_lpstat_integration.rs: Integration test end-to-end submit job via example lp and verify via lpstat.

Supported options (subset)

  • lp: --help -- -d -E -h -U -t -n -q -o -H -P -s + stdin (-)
  • lpstat: --help -H -d -e -r -s -t -a -c -p -v -o -u -W -R -l -D -E -h -U

How to test it

cargo test --all -- --nocapture
cargo build --examples

echo "hello" > sample.txt
./target/debug/examples/lp -d PDF sample.txt
./target/debug/examples/lpstat -t
./target/debug/examples/lpstat -W all -o PDF
Test Output (lpstat -t + lp via stdin)

example implementation | current system implementation

Screenshot 2026-03-02 145044

lpstat (CodeFlow)

Added a Mermaid flowchart documenting the high-level lpstat execution path (arg parsing → context setup → action dispatch → job/device/printer queries), since the implementation is large and hard to scan quickly.

flowchart TB
    A["main"] --> B["run"]
    B --> C["parse_args"]
    C --> E{"for Step in commands"}
    E -- SetLongStatus --> SLS["ctx.long_status = max"]
    E -- SetRanking --> SRK["ctx.ranking = v"]
    E -- SetEncryption --> SEN["set_encryption"]
    E -- SetWhich --> SW["ctx.which = v"]
    E -- SetServer --> SSV["set_server + ctx.refresh_dests"]
    SSV --> SSV1["get_all_destinations"]
    E -- SetUser --> SUS["set_user"]
    E -- Action --> ACT["Action::run"]
    ACT --> AR{"match Action"}
    AR -- ShowServerAndPort --> AS1["get_server + ippPort"]
    AR -- ShowDefault --> AS2["Destinations::get_default"]
    AR -- ListDestinations --> AS3["iterate ctx.dests"]
    AR -- ShowSchedular --> AS4["scheduler_is_running"]
    AR -- ShowSummary --> AS5["show_default + show_classes + show_devices"]
    AR -- ShowAll --> AS6["scheduler_is_running + show_default + show_classes + show_devices + show_accepting + show_printers + show_jobs"]
    AR -- ShowAccepting --> AA["show_accepting"]
    AR -- ShowClasses --> AC["show_classes"]
    AR -- ShowPrinters --> AP["show_printers"]
    AR -- ShowDevices --> AV["show_devices"]
    AR -- ShowJobsByDest --> AO["show_jobs user=None dest=filter"]
    AR -- ShowJobsByUser --> AU["show_jobs user=filter dest=None"]
    AR -- ShowJobsBareArg --> AB["show_jobs user=arg dest=None"]
    AO --> SJ["show_jobs"]
    AU --> SJ
    AB --> SJ
    SJ --> SJ1{"ctx.which"} & SJ5["jobs.retain match_list"] & SJ6{"needs_extras?"} & SJ9["print rows"]
    SJ1 -- NotCompleted --> SJ2["get_active_jobs"]
    SJ1 -- Completed --> SJ3["get_completed_jobs"]
    SJ1 -- All --> SJ4["get_jobs"]
    SJ6 -- yes --> SJ7["get_job_extras"]
    SJ6 -- no --> SJ8["extras = empty"]
    SW --> W2["controls show_jobs source"]
    SJ9 --> H2["format_time"]
    SJ5 --> H3["match_list"]
Loading

@Abd002 Abd002 marked this pull request as draft March 2, 2026 14:02
@Abd002 Abd002 marked this pull request as ready for review March 3, 2026 16:49
@Abd002 Abd002 force-pushed the lp-lpstat branch 2 times, most recently from 6bef114 to 2fcc412 Compare March 7, 2026 23:07
@Gmin2
Copy link
Copy Markdown
Collaborator

Gmin2 commented Mar 9, 2026

Also I think I have flag it earlier about the cli thing, this is a library not a cli implementation so the example should not contain the cli that yu are making (Please keep this in mind for future )

See the other examples that were already there, yu wil need to make small specific examples for lpstat

And also please split the pr into digestible size that a maintainner can review, reviewing 1764+ lines of code with a single commit is pretty difficult,either make small commits showing what done and compress it into a pr or make small small pr

Thanks

@Abd002
Copy link
Copy Markdown
Contributor Author

Abd002 commented Mar 9, 2026

Also I think I have flag it earlier about the cli thing, this is a library not a cli implementation so the example should not contain the cli that yu are making (Please keep this in mind for future )

See the other examples that were already there, yu wil need to make small specific examples for lpstat

And also please split the pr into digestible size that a maintainner can review, reviewing 1764+ lines of code with a single commit is pretty difficult,either make small commits showing what done and compress it into a pr or make small small pr

Thanks

I got it, I’ll break this PR down into smaller PRs that are easier to review.

@Abd002
Copy link
Copy Markdown
Contributor Author

Abd002 commented Mar 9, 2026

I can split it into small focused examples under examples/lpstat/ for things like scheduler status, classes, and the other missing parts, with the goal of improving library examples rather than reimplementing the lpstat CLI.

yes,

@Abd002 Abd002 marked this pull request as draft March 11, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants