Dynamic Configurations

As you can learn in Command-Line Options, it’s possible to provide additional parameters using the -p option.

Such parameters can be used the same way as any other parameter (${parameter_name}), but they are evaluated statically before the configuration JSON is parsed. Therefore, it’s possible to use them to alter the behavior signifficantly.

Dynamic Upload & Download 🔗

E.g., you can re-use the same configuration to upload different sources:

{ 

  "upload": { 
    "files": "${uploadPath}/src/locales/**/translations.json",
    "path": "${uploadPath}", 
    // ... 
  } 
  
}

Now, you can just invoke our CLI like this:

localazy upload -p uploadPath:app
localazy upload -p uploadPath:library1
localazy upload -p uploadPath:library2

Similar approach can be applied to the download section to select on where to store the resulting files or how to filter them based on specific parameters.

In a way, using additional parameters like this is similar to using groups, but you don’t need to define the corresponding section beforehand.

Changing Parameters Dynamically 🔗

From the latest CLI version (1.6.5+), it’s possible to define parameters as strings even for boolean and numberic ones allowing to use a construction like this:

{

  "upload": {
    "folder": "${folder}",
    "deprecate": "${deprecate}",
    "filterSource": "${filterSource}",
    "features": ["${feature1}", "${feature2}"],
    // ...
  }

}

Now, you can just invoke our CLI:

localazy upload -p folder:. -p deprecate:none -p filterSource:true -p feature1:filter_untranslated -p feature2:

Please note that empty items in features are filtered out and not evaluated allowing to use additional parameters in described way.

Whole JSON Blocks 🔗

As additional parameters are evaluated before the JSON is parsed, you can use them for an ugly hacks like this one:

{

  "upload": {
    ${json1}
    "type": "json",
    "files": "locales/*.json"
  }

}

Now, by invoking our CLI with the command below, you can provide a part of the configuration JSON dynamically.

localazy upload -p 'json1:"importAsNew": true,'

However, this approach means that the input configuration file is no longer a valid JSON.