# Unity Gaming Services CLI

> Create, deploy, and manage Cloud Code scripts using the Unity Gaming Services command-line interface.

[Unity Gaming Services CLI](https://services.docs.unity.com/guides/ugs-cli/latest/general/overview)를 사용하여 Cloud Code 스크립트와 상호 작용할 수 있습니다. CLI를 사용하면 커맨드 라인에서 Cloud Code 스크립트를 생성, 배포, 관리할 수 있습니다.

## 필수 조건##prerequisites

CLI에 대해 자세히 알아보려면 [Unity Gaming Services CLI 시작하기 가이드](https://services.docs.unity.com/guides/ugs-cli/latest/general/get-started/install-the-cli/)에 나와 있는 단계를 따르십시오.

이 가이드를 따르려면 먼저 다음 작업을 완료해야 합니다.

1. [UGS CLI를 설치합니다](https://services.docs.unity.com/guides/ugs-cli/latest/general/get-started/install-the-cli/).

2. 다음과 같이 프로젝트 ID와 환경을 구성합니다.
   `ugs config set project-id <your-project-id>`
   `ugs config set environment-name <your-environment-name>`

3. [Cloud Code](https://services.docs.unity.com/docs/service-account-auth/index.html#cloud-code-editor)와 [환경 관리](https://services.docs.unity.com/docs/service-account-auth/index.html#unity-environments-admin)에 필요한 역할을 사용하여 서비스 계정을 구성합니다. [인증 받기](https://services.docs.unity.com/guides/ugs-cli/latest/general/get-started/get-authenticated/)를 참고하십시오.

## CLI 사용##using-the-cli

커맨드와 옵션이 모두 나와 있는 레퍼런스가 필요한 경우, [Cloud Code 커맨드 라인 기술 자료](https://services.docs.unity.com/guides/ugs-cli/latest/cloud-code/Cloud%20Code%20Command%20Line/overview)를 참고하십시오.

> **Note:**
>
> **참고:** `ugs cloud-code scripts` 커맨드는 `ugs cc s`로도 사용할 수 있습니다.

### 스크립트 배포##deploy-scripts

`new-file` 커맨드를 실행하여 로컬에서 샘플 코드가 포함된 스크립트를 생성할 수 있습니다.

```bash
ugs cloud-code scripts new-file <file-name>
```

`Deploy` 커맨드를 사용하면 로컬 스크립트를 원격 환경으로 승격하여 한 번에 퍼블리시할 수 있습니다. 로컬 스크립트를 배포해야 게임 클라이언트에서 사용할 수 있습니다.

```bash
ugs deploy <path-to-script-file> <path-to-script-file>
```

```bash
ugs deploy <path-to-directory>
```

### 스크립트 검색##retrieve-scripts

배포된 스크립트에 대한 정보를 검색하려면 다음과 같은 커맨드를 실행합니다.

```bash
ugs cloud-code scripts get <script-name>
```

다음과 같은 커맨드를 실행하여 현재 Cloud Code에 배포된 모든 스크립트를 나열할 수도 있습니다.

```bash
ugs cloud-code scripts list
```

`Fetch` 커맨드를 사용하면 원격 환경에서 여러 Cloud Code 스크립트를 한 번에 가져올 수 있습니다. 제공되는 경로는 스크립트를 가져올 디렉토리입니다.

```bash
ugs fetch <path>
```

> **Note:**
>
> **참고:** 서비스에서 선언된 파라미터가 있는데 서비스 스크립트 코드에는 파라미터가 없는 경우, Fetch 커맨드는 로컬 스크립트 코드를 업데이트하여 파라미터를 추가합니다. [파라미터 파싱](https://services.docs.unity.com/guides/ugs-cli/latest/cloud-code/Cloud%20Code%20Command%20Line/parameter-parsing/)을 참고하십시오.

### 환경 동기화##environment-synchronization

한 환경의 모든 스크립트를 다른 환경에 옮겨 배포할 수 있습니다.

다음과 같은 커맨드를 실행하여 현재 환경에 있는 모든 스크립트의 아카이브를 생성합니다.

```bash
ugs cloud-code scripts export <out-dir> <file-name>
```

그러면 다음과 같은 커맨드를 실행하여 스크립트를 임포트하고 다른 환경에 배포할 수 있습니다.

```bash
ugs cloud-code scripts import <in-dir> <file-name> --environment-name <environment-name>
```

스크립트는 자동으로 퍼블리시됩니다.

> **Note:**
>
> **참고:** `Import`는 기본적으로 환경을 덮어쓰지 않습니다. 임포트 전에 기존 스크립트를 삭제하려는 경우 `--reconcile` 플래그를 사용하십시오.

### 스크립트 삭제##delete-script

기존 스크립트를 삭제하려면 다음과 같은 커맨드를 실행합니다.

```bash
ugs cloud-code scripts delete <script-name>
```

## 추가 리소스##additional-resources

* [배포 샘플(영문)](https://github.com/Unity-Technologies/unity-gaming-services-cli/blob/main/Samples/Deploy/instructions.md#deploy-cloud-code-script)
* 커맨드를 통해 스크립트 파라미터를 처리하는 방법을 알아보려면 [파라미터 파싱](https://services.docs.unity.com/guides/ugs-cli/latest/cloud-code/Cloud%20Code%20Command%20Line/parameter-parsing/)을 참고하십시오.
