# Parameter parsing for scripts

> Understand how the create, update, and deploy commands parse parameters from a Cloud Code script.

[Create script], [Update script], and [Deploy] commands evaluate parameters from a Cloud Code script.

In the example [Script.js], one parameter with name `range` and type `NUMERIC` is parsed and uploaded to UGS.

For more details, check \[Declare parameters in the script].

> **Warning:**
>
> UGS CLI uses Node.js with version > 14.0.0 to parse Cloud Code parameters. Please install Node.js on your system and configure its executable path in your PATH environment variable.

## Append Parameter into Cloud Code Script during Fetch

To ensure that the [Fetch] command is fetching the exact Cloud Code script information from the service, UGS CLI will look up parameters declared for the script in the service.

If there are parameters declared from the service and there are no parameter in service script code, the [Fetch] command will update local script code and declare parameters. This means a section like this might be appended into your local script code:

```js
module.exports.params = {
    //Parameters declared in service
}
```

If there are any parameters declared in-script from the service, UGS CLI will not update the parameters.

> **Warning:**
>
> It is always recommended to declare and update parameters in-script code to prevent getting outdated parameters.

## Parsing Limitations

[Create script] and [Update script] evaluate the given Cloud Code script to parse the parameters. As a result, these commands cannot parse parameters if you declare them at the beginning and overwrite/delete them after.

For example, this script is problematic:

```js
const _ = require("lodash-4.17");

const NUMBER_OF_SIDES = 6;

module.exports.params = {
    sides: "NUMERIC"
};

module.exports = async ({ params, context, logger }) => {
    // ...
};

// Functions can exist outside of the script wrapper
function rollDice(sides) {
    return _.random(1, sides);
}
```

The script defines `module.exports.params` at the beginning, but then it is overwritten by `module.exports = async ...`, so **Create script** or **Update script** cannot parse the parameters.

[Create script]: ./commands/scripts/create

[Update script]: ./commands/scripts/update

[Deploy]: ../general/base-commands/deploy

[Fetch]: ../general/base-commands/fetch

[Script.js]: https://github.com/Unity-Technologies/unity-gaming-services-cli/blob/main/Samples/Deploy/CloudCode/Script/Script.js
