Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Make cronnext's output be YAML #190

Open
petdance opened this issue Sep 10, 2024 · 1 comment
Open

Request: Make cronnext's output be YAML #190

petdance opened this issue Sep 10, 2024 · 1 comment

Comments

@petdance
Copy link

I'd like to process the output of cronnext using tools like yq. The output that cronnext gives is mostly YAML-like, but not entirely so.

This crontab line:

15 17 * * * echo "Out of my brain on the train" > /tmp/foo.log

gets printed by cronnext as:

next: 1726006500
nextjobs:
  - user: alester
    cmd: "echo "Out of my brain on the train" > /tmp/foo.log"
    flags: 0x0C
    flagnames: DOM_STAR|DOW_STAR
    delay: 0
    next: 1726006500
    nextstring: Tue Sep 10 17:15:00 2024

but a tool like yq can't parse that because the double quotes in the cmd: value aren't escaped. It would be fine if it was:

next: 1726006500
nextjobs:
  - user: alester
    cmd: "echo \"Out of my brain on the train\" > /tmp/foo.log"
    flags: 0x0C
    flagnames: DOM_STAR|DOW_STAR
    delay: 0
    next: 1726006500
    nextstring: Tue Sep 10 17:15:00 2024

I understand that nowhere does cronnext say that its output is YAML, and it would be great if it could be made so. If you didn't want to change the output because existing tools that use the output could break, an optional --yaml option to make the strict YAML format output would work, too.

I don't know what other things might have to change in the output to be correct YAML. I know there are a bunch of special characters and sequences that need to be escaped, but I don't know the full list. I figure there are plenty of libraries out there to do the dirty work.

@t8m
Copy link
Member

t8m commented Sep 11, 2024

I am not sure I want to add dependencies on external libraries.

If the only problem is escaping various characters in the cmd string, I would say we do not need any compatibility option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants