Rust-DAY1
sun
- ๊ฐ๋จํ ํ๋ก๊ทธ๋จ์ ๋ฐฐ์ฐ๋ฉด์ Rust ๋ฅผ ๋ฐฐ์์ ๋จ์ฃผ์!
- multiple hostย ์ shell ๋ช
๋ น์ด๋ฅผ ๋ณด๋ด๊ณ ๊ทธ๊ฒ์ ๋ณด์ฌ์ฃผ๋ ๋จ์ํ CLI ํ๋ก๊ทธ๋จ(์ฌ์ค python ansible ์กฐํฉ์ด๋ฉด ๊ธ๋ฐฉ ๋ ๊ฒ ๊ฐ์ง๋ง...)
- github action ์ CI ๊ด๋ จ ์คํธ๋ฆฝํธ ์ ์ํ๊ณ ์์!
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Check Lint
run: cargo fmt --all -- --check --verbose
- ์ธ์ ๋ PR ๋ฆฌ๋ทฐ ๋ฐ ํผ๋๋ฐฑ์ ํ์ ์ ๋๋ค.
๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ฑํ๊ธฐ
- Jetbrains Intellij + Rust plugin ์ผ๋ก ์ธํ ์๋ฃ
- vscode ์ ํ๋ฌ๊ทธ์ธ์ Rust ์ Rust(rls) ๋ง ์ค์นํด์ ์ธ ์ ์์ง๋ง ๊ฐ์ ์ฌ์ฉ์(๋)์ ๊ฒฝํ์ผ๋ก ๊ฐ๋ฐํ๊ณ ์ถ์ด์ jetbrains ๊ณ์ด ์ ํ
-
์๊ฐ๋ณด๋ค ์๋์์ฑ์ด ๋์์ง ์์์ ์ฌ์ฉ์ค
clap
- CLI ํ๋ก๊ทธ๋จ์์ help ๋ arg ๋ค์ ๋ฐ๋ ๊ฒ์ ๊ตฌ์ฑํ๊ธฐ ์ํด์ clap ๋ผ๋ crate ๋ฅผ
Cargo.toml
์ ์ถ๊ฐํ๋ค.
[dependencies]
clap = "~2.33.0"
Custom Type ์ ์ํ๊ธฐ
- clap ์ผ๋ก command line argument ๋ฅผ ๊ฐ์ ธ์๋๋ฐ host ๋ฅผ ์ ์ํ host.yaml ์ ๊ฒฝ๋ก์ ์
๋ ฅํ shell command ๋ฅผ ๋ถ๋ฆฌํ๊ธฐ ์ํด์
parse_arg
ํจ์๋ฅผ ๊ตฌํ - Tuple ํํ๋ก
(String, String)
์ด๋ ๊ฒ ๋ฆฌํดํ๋ฉด ๋ ๋ช ์์ ์ด์ด์ CustomType ์ ์ ์ํด๋ณธ๋ค.
type HostFilePath = String;
type Input = String;
Reference
** ์์ง ๋ชจ๋ฅด๋๊ฒ :**
- Custom Error ๋ฅผ ๋ง๋ค๊ณ ๊ทธ๊ฒ์ throw ํ๋ ๋ฐฉ๋ฒ?
- intellij ์์ rust debug mode ์ฐ๊ฒฐ ํ๋ ๋ฒ?
#rust
#100DaysOfRust