|
1 |
| -# Generate Swift models for ROS message files. |
| 1 | +[](https://img.shields.io/badge/Swift-5-DE5D43) |
| 2 | +[](https://img.shields.io/badge/Platforms-all-sucess) |
| 3 | +[](https://github.com/DimaRU/Msg2swift/actions/workflows/test.yml) |
| 4 | + |
| 5 | +# Msg2swift - Generate Swift models for ROS message files. |
| 6 | + |
| 7 | + |
| 8 | +## Description |
| 9 | + |
| 10 | +Msg2swift help you generate swift models from ROS .msg files. Intended for use with [CDRCodable](https://github.com/DimaRU/CDRCodable). |
| 11 | +In particular Msg2swift generates proper CodableKeys for encoding and decoding fixed-size arrays. |
| 12 | + |
| 13 | + |
| 14 | +## Installation for use with command line |
| 15 | + |
| 16 | +#### Homebrew |
| 17 | + |
| 18 | +Run the following command to install using [Homebrew](https://brew.sh/): |
| 19 | + |
| 20 | +```console |
| 21 | +brew install DimaRU/formulae/msg2swift |
| 22 | +``` |
| 23 | + |
| 24 | +#### Swift package manager command plugin |
| 25 | + |
| 26 | +When you add [CDRCodable](https://github.com/DimaRU/CDRCodable) dependency to your project: |
| 27 | + |
| 28 | +```swift |
| 29 | +.package(url: "https://github.com/DimaRU/CDRCodable", from: "1.0.0") |
| 30 | +``` |
| 31 | +you may use msg2swift SPM command line plugin: |
| 32 | + |
| 33 | +```console |
| 34 | +swift package plugin --allow-writing-to-package-directory msg2swift ../../msg/BatteryState.msg -o model |
| 35 | +``` |
| 36 | + |
| 37 | + |
| 38 | +## Command line USAGE |
| 39 | + |
| 40 | +``` |
| 41 | +USAGE: msg2swift [<options>] <file> ... |
| 42 | +
|
| 43 | +ARGUMENTS: |
| 44 | + <file> .msg file(s) to convert. |
| 45 | +
|
| 46 | +OPTIONS: |
| 47 | + --let/--var Use var or let for model properties. (default: --let) |
| 48 | + --struct/--class Struct or class declaration. (default: --struct) |
| 49 | + --codable/--encodable/--decodable |
| 50 | + Model declaration suffix. (default: --codable) |
| 51 | + --snake-case/--no-snake-case |
| 52 | + Convert property names from "snake_case" to "camelCase" (default: --snake-case) |
| 53 | + -c, --compact Compact generated code. |
| 54 | + Strip all comments and remove empty lines. |
| 55 | + --detect-enum/--no-detect-enum |
| 56 | + Detect enums. (default: --detect-enum) |
| 57 | + Detect and group constants into Swift enum. |
| 58 | + -n, --name <name> Object name. |
| 59 | + By default file name used. |
| 60 | + -o, --output-directory <path> |
| 61 | + The output path for generated files. |
| 62 | + By default generated files written to the current directory. |
| 63 | + -s, --silent Don't print processed file names. |
| 64 | + --version Show the version. |
| 65 | + -h, --help Show help information. |
| 66 | +``` |
| 67 | + |
| 68 | +## Build |
| 69 | + |
| 70 | +Use swift package manager for build. |
| 71 | + |
| 72 | +```console |
| 73 | +https://github.com/DimaRU/Msg2swift.git |
| 74 | +cd Msg2swift |
| 75 | +swift build |
| 76 | +``` |
| 77 | + |
0 commit comments