lenra_cli 1.0.0-beta.14

The Lenra command line interface
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<div id="top"></div>
<!--
*** Thanks for checking out the Best-README-Template. If you have a suggestion
*** that would make this better, please fork the repo and create a pull request
*** or simply open an issue with the tag "enhancement".
*** Don't forget to give the project a star!
*** Thanks again! Now go create something AMAZING! :D
-->



<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]

# Lenra cli

The Lenra's command line interface.

[Report Bug](https://github.com/lenra-io/lenra_cli/issues)
ยท
[Request Feature](https://github.com/lenra-io/lenra_cli/issues)

<!-- GETTING STARTED -->
## Getting Started

### Prerequisites

To build and run the Lenra elements that handle your app, the Lenra CLI needs [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/).

You can also install the [Docker buildx command](https://docs.docker.com/build/buildx/install/) to use the [Buildkit optimization given by Dofigen](https://github.com/lenra-io/dofigen).

Install the Lenra CLI using one of the next possibilities.

#### Download the binary

You can download the binary from [the release page](https://github.com/lenra-io/lenra_cli/releases) and add it to your path environment variable.

#### Cargo install

First install Cargo, the Rust package manager: https://doc.rust-lang.org/cargo/getting-started/installation.html

Then use the next command to install the Lenra's cli:

```bash
cargo install lenra_cli
```

#### Build it from sources

First install Cargo, the Rust package manager: https://doc.rust-lang.org/cargo/getting-started/installation.html

Then clone this repository and install it with Cargo:

```bash
git clone https://github.com/lenra-io/lenra_cli.git
cargo install --path .
```

<p align="right">(<a href="#top">back to top</a>)</p>

### How to use it

Use the help options to understand how to use it:

```bash
$ lenra --help
lenra_cli 0.0.0
The Lenra command line interface

USAGE:
    lenra <SUBCOMMAND>

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

SUBCOMMANDS:
    build    Build your app in release mode
    dev      Start the app in an interactive mode
    help     Print this message or the help of the given subcommand(s)
    init     Generates dockerfile and docker compose file with the init command
    logs     View output from the containers
    new      Create a new Lenra app project
    start    Start your app previously built with the build command
    stop     Stop your app previously started with the start command
```

### Subcommands

This tools contains many subcommands to help you doing what you need.

- [new]#new: creates a new Lenra app project
- [build]#build: builds the Lenra app of the current directory
- [start]#start: starts your app previously built with the build command
- [logs]#logs: displays output from the containers
- [stop]#stop: stops your app previously started with the start command
- [dev]#dev: starts your app in dev mode
- [init]#init: Generates Docker and Docker Compose files

#### new

This subcommand creates a new Lenra app project from a given template and in a given directory.
The target directory must not exist.

```bash
$ lenra new --help
lenra-new 
Create a new Lenra app project

USAGE:
    lenra new <TEMPLATE> <PATH>

ARGS:
    <TEMPLATE>    The project template from which your project will be created. For example,
                  defining `rust` or `template-rust` will use the next one:
                  https://github.com/lenra-io/template-rust You can find all our templates at
                  this url:
                  https://github.com/orgs/lenra-io/repositories?q=&type=template&language=&sort=stargazers
                  You also can set the template project full url to use custom ones
    <PATH>        The project path

OPTIONS:
    -h, --help    Print help information
```

#### build

This subcommand builds the Lenra app of the current directory.
The app configuration are defined by a [configuration file](#configuration-file).

```bash
$ lenra build --help
lenra-build 
Build your app in release mode

USAGE:
    lenra build [OPTIONS]

OPTIONS:
        --config <CONFIG>    The app configuration file [default: lenra.yml]
        --expose             Exposes all services ports
    -h, --help               Print help information
```

#### start

This subcommand starts the Lenra app of the current directory previously built.

```bash
$ lenra start --help
lenra-start 
Start your app previously built with the build command

USAGE:
    lenra start [OPTIONS]

OPTIONS:
        --config <CONFIG>    The app configuration file [default: lenra.yml]
        --expose             Exposes all services ports
    -h, --help               Print help information
```

#### logs

This subcommand displays output from the containers.

```bash
$ lenra logs --help
lenra-logs 
View output from the containers

USAGE:
    lenra logs [OPTIONS] [SERVICES]...

ARGS:
    <SERVICES>...    The logged service list [default: app] [possible values: app, devtool,
                     postgres]

OPTIONS:
    -f, --follow           Follow log output
    -h, --help             Print help information
        --no-color         Produce monochrome output
        --no-log-prefix    Don't print prefix in logs
        --since <SINCE>    Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g.
                           42m for 42 minutes)
    -t, --timestamps       Show timestamps
        --tail <TAIL>      Number of lines to show from the end of the logs for each container
                           [default: all]
        --until <UNTIL>    Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative
                           (e.g. 42m for 42 minutes)
```

#### stop

This subcommand stops the Lenra app of the current directory and removes the Docker Compose elements.

```bash
$ lenra stop --help
lenra-stop 
Stop your app previously started with the start command

USAGE:
    lenra stop [OPTIONS]

OPTIONS:
        --config <CONFIG>    The app configuration file [default: lenra.yml]
    -h, --help               Print help information
```

#### dev

This subcommand starts the Lenra app of the current directory in dev mode.

```bash
$ lenra dev --help
lenra-dev 
Start the app in an interactive mode

USAGE:
    lenra dev [OPTIONS]

OPTIONS:
        --config <CONFIG>    The app configuration file [default: lenra.yml]
        --expose             Exposes all services ports
    -h, --help               Print help information
```

#### init

This subcommand generates Docker and Docker Compose files.

```bash
$ lenra init --help
lenra-init 
Generates dockerfile and docker compose file with the init command

USAGE:
    lenra init [OPTIONS]

OPTIONS:
        --config <CONFIG>    The app configuration file [default: lenra.yml]
    -h, --help               Print help information
```

## dev interactive commands

When using the [dev](#dev) sub-command, the CLI enters an interactive mode.
The interactive mode builds and starts the app and then displays its logs.

When the CLI receive a `Ctrl + C` signal in dev mode, it displays an interactive command prompt.
Here is the `help` interactive command result:

```bash
[lenra]$ help
lenra_cli 
The Lenra interactive command line interface

USAGE:
    lenra <SUBCOMMAND>

OPTIONS:
    -h, --help    Print help information

SUBCOMMANDS:
    continue    Continue the previous logs command since the last displayed logs
    help        Print this message or the help of the given subcommand(s)
    logs        View output from the containers
    reload      Reload the by rebuilding and restarting it
    stop        Stop your app previously started with the start command
```

### Subcommands

This tools contains many subcommands to help you do what you need.

- [continue]#continue: continues the previous logs command since the last displayed logs
- [logs]#logs: displays output from the containers
- [reload]#reload: reloads the app by rebuilding and restarting it
- [stop]#stop: stops your app previously started with the start command

#### continue

This subcommand continues the previous logs command since the last displayed logs.

```bash
[lenra]$ continue --help
lenra-continue 
Continue the previous logs command since the last displayed logs

USAGE:
    lenra continue

OPTIONS:
    -h, --help    Print help information
```

#### reload

This subcommand reloads the app by rebuilding and restarting it.

```bash
[lenra]$ reload --help
lenra-reload 
Reload the app by rebuilding and restarting it

USAGE:
    lenra reload

OPTIONS:
    -h, --help    Print help information
```

### Configuration file

The Lenra's configuration file describes your Lenra app configurations, like API versions or how to build it.

Here is an example using a Dofigen file:

```yaml
componentsApi: "1.0"
generator:
  dofigen: dofigen.yml
```

#### Configuration

The configuration is the main element of the file:

| Field            | Type             | Description                   |
|------------------|------------------|-------------------------------|
| `componentsApi`  | String           | The components API version    |
| `generator`      | [Generator]#generator  The generator configuration |

#### Generator

The generator define your application is built. There are many configurators:

- [Dofigen]#dofigen
- [Docker]#docker

##### Dofigen

The Dofigen generator use a [Dofigen](https://github.com/lenra-io/dofigen) configuration to generate the Docker image.

The Dofigen configuration can be the path to a Dofigen file or it content directly.

##### Docker

The Docker generator use a Dockerfile to generate the Docker image.

The Dockerfile can be the path to a file or it content directly.

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- CONTRIBUTING -->
## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please open an issue with the tag "enhancement" or "bug".
Don't forget to give the project a star! Thanks again!

<p align="right">(<a href="#top">back to top</a>)</p>



<!-- LICENSE -->
## License

Distributed under the **MIT** License. See [LICENSE](./LICENSE) for more information.

<p align="right">(<a href="#top">back to top</a>)</p>



<!-- CONTACT -->
## Contact

Lenra - [@lenra_dev](https://twitter.com/lenra_dev) - contact@lenra.io

Project Link: [https://github.com/lenra-io/lenra_cli](https://github.com/lenra-io/lenra_cli)

<p align="right">(<a href="#top">back to top</a>)</p>


<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/lenra-io/lenra_cli.svg?style=for-the-badge
[contributors-url]: https://github.com/lenra-io/lenra_cli/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/lenra-io/lenra_cli.svg?style=for-the-badge
[forks-url]: https://github.com/lenra-io/lenra_cli/network/members
[stars-shield]: https://img.shields.io/github/stars/lenra-io/lenra_cli.svg?style=for-the-badge
[stars-url]: https://github.com/lenra-io/lenra_cli/stargazers
[issues-shield]: https://img.shields.io/github/issues/lenra-io/lenra_cli.svg?style=for-the-badge
[issues-url]: https://github.com/lenra-io/lenra_cli/issues
[license-shield]: https://img.shields.io/github/license/lenra-io/lenra_cli.svg?style=for-the-badge
[license-url]: https://github.com/lenra-io/lenra_cli/blob/master/LICENSE.txt