TARGETS
  • Read Me
  • Introduction
    • Motivation
    • Project Goals
    • What is Targets?
    • Who is Targets for?
    • Common Use Cases
    • What is a "target"?
    • What is a "composition"?
    • What is an "operation"?
    • What is a "spec"?
    • What does a Targets implementation look like?
    • Background
  • Learn Targets
    • Hello World
    • Config - Part 1
    • Config - Part 2
    • Bindings
    • Composition
    • Loaders
    • Project Structure
    • More Examples
  • Reference
    • System Requirements
    • Installation
    • Configuration
    • Settings
    • Global Store
    • Scheduler
    • Operations
      • Binding Operations
      • Predicating Operations
      • Debugging Operations
    • TTY Mode
Powered by GitBook
On this page
  • @when
  • Syntax
  • Arguments
  • Examples
  • @when-not
  • Examples
  • @exit-when
  • Syntax
  • Arguments
  • Example
  • @proceed-when
  • Examples
  1. Reference
  2. Operations

Predicating Operations

Note: In the current implementation, the ambiguity of the meaning of the second argument in the predicate operations can present collision problems. Syntax changes are being considered.

@when

Use the when operation to predicate target execution without having to write a separate composition.

It considers the value at a given location from within the global store and then:

a) executes a given target if the source value evaluates as truthy b) compares the source value to another value in the global store as resolved from another given keypath. c) compares the source value to a literal string value if that value does not resolve as a keypath to a value in the global store.

Syntax

@when/{source keypath}[::{source keypath OR string literal}]::{target name}

Arguments

  • source keypath - keypath from which to resolve a value from the global store.

  • source keypath OR string literal (optional) - keypath from which to resolve a value from the global store OR a string literal. The value, whether resolved from the store or given, will be used to make a loose equality comparison with the value resolved from the first argument.

  • target name - name of target to execute based on resolution of predicate.

Examples

--config.friend true @when/config.friend::greet # greet will be called
--config.friend false @when/config.friend::greet # greet will NOT be called
--config.a foo --config.b foo @when/config.a::config.b::greet # greet will be called
--config.a foo --config.b bar @when/config.a::config.b::greet # greet will NOT be called
--config.a foo @when/config.a::foo::greet # greet will be called
--config.a foo @when/config.a::bar::greet # greet will NOT be called

@when-not

The @when operation with the result of the predicate negated.

Examples

# greet will be called
--config.enemy false @when-not/config.enemy::greet

# greet will NOT be called
--config.enemy true @when-not/config.enemy::greet

@exit-when

Use the exit-when operation to predicate process exit.

It considers the value at a given location from within the global store and then:

a) exit the process if the source value evaluates as truthy b) compares the source value to another value in the global store as resolved from another given keypath. c) compares the source value to a literal string value if that value does not resolve as a keypath to a value in the global store.

Syntax

@exit-when/{source keypath}[::{source keypath OR string literal}]

Arguments

  • source keypath - keypath from which to resolve a value from the global store.

  • source keypath OR string literal (optional) - keypath from which to resolve a value from the global store OR a string literal. The value, whether resolved from the store or given, will be used to make a loose equality comparison with the value resolved from the first argument.

Example

# if health-check target returns an error process will exit
health-check @exit-when/result.health-check.error

@proceed-when

The @exit-when operation with the result of the predicate negated.

Examples

# if health-check target returns status of healthy, the process contiues
health-check @proceed-when/result.health-check.status::healthy
PreviousBinding OperationsNextDebugging Operations

Last updated 6 years ago