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

ipptool: Add support for conditional ATTR/MEMBER directives #3

Closed
michaelrsweet opened this issue May 17, 2022 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request priority-medium
Milestone

Comments

@michaelrsweet
Copy link
Member

From @wifiprintguy, ippsample issue 254:

It would be very useful if the IF-DEFINED and IF-NOT-DEFINED predicates could be used in EXPECT and MEMBER directives so that attributes could be conditionally included in a request. For instance:

{
    SKIP-IF-NOT-DEFINED HAVE_BALING

    NAME '[BALING-2] Print requesting baling using finishings'
    OPERATION Print-Job

    GROUP operation-attributes-tag
        ATTR charset attributes-charset utf-8
        ATTR language attributes-natural-language en
        ATTR uri printer-uri $uri
        ATTR name requesting-user-name $user
        ATTR mimeMediaType document-format $filetype
    
    GROUP job-attributes-tag
        ATTR integer copies 1
        ATTR enum finishings 12  # bale
        ATTR integer job-pages-per-set 3 IF-DEFINED HAS_JOB_PAGES_PER_SET
        ATTR integer copies 2 IF-NOT-DEFINED HAS_JOB_PAGES_PER_SET

    FILE $filename

    STATUS successful-ok

    EXPECT job-id OF-TYPE integer IN-GROUP job-attributes-tag WITH-VALUE >0 COUNT 1
    EXPECT job-uri OF-TYPE uri IN-GROUP job-attributes-tag COUNT 1
}

These two lines:

        ATTR integer job-pages-per-set 3 IF-DEFINED HAS_JOB_PAGES_PER_SET
        ATTR integer copies 2 IF-NOT-DEFINED HAS_JOB_PAGES_PER_SET

are currently illegal. To achieve this you have to write 2+ tests that are nearly identical, which is not an optimal solution.

@michaelrsweet michaelrsweet added enhancement New feature or request priority-medium labels May 17, 2022
@michaelrsweet michaelrsweet self-assigned this May 17, 2022
@michaelrsweet
Copy link
Member Author

We need slightly different syntax:

ATTR-IF-DEFINED VARIABLE_NAME syntax name value
ATTR-IF-NOT-DEFINED VARIABLE_NAME syntax name value

@michaelrsweet
Copy link
Member Author

[master d7f7d2a] Add ATTR-IF-DEFINED and ATTR-IF-NOT-DEFINED directive support (Issue #3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-medium
Projects
Development

No branches or pull requests

1 participant