github.com/omnigres/cli@v0.1.4/README.md (about) 1 # Omnigres CLI 2 3 This is a Command Line Interface to interact with [Omnigres](https://github.com/omnigres/omnigres). 4 Also check the [Omnigres documentation](https://docs.omnigres.org/) for more info about the platform. 5 6 ## Before you start 7 8 In order to provision an Omnigres cluster you should have the Docker CLI installed. 9 Check their [Get Started page](https://www.docker.com/get-started/) to install the Docker tools on your system. 10 11 ## Quick start 12 13 Download binaries from the [releases page](https://github.com/omnigres/cli/releases) for your architecture and place within your **PATH**. Then try calling it without parameters 14 15 ```sh 16 omnigres 17 ``` 18 19 This will show a list of all available commands. 20 21 ### Your first HTTP application 22 23 To create an application from scratch start using the init command. But we should start in a new root directory for your Omnigres projects. 24 25 ```sh 26 mkdir og_projects 27 cd og_projects 28 omnigres init first_app 29 ``` 30 31 Now run the server with `omnigres start`. 32 33 ```sh 34 omnigres start 35 ``` 36 37 You should see all the available endpoints once the command finishes. 38 39 ```sh 40 INFO Omnigres Orb cluster started. 41 omnigres (Postgres): postgres://omnigres:omnigres@172.19.0.3:5432/omnigres 42 omnigres (HTTP): http://172.19.0.3:8081 43 ``` 44 45 You should have now a `first_app/src` directory. We can place a little function and router there. 46 Just copy the contents below into `first_app/src/hello.sql`. 47 48 ```sql 49 create extension omni_httpd cascade; 50 51 create function my_handler(request omni_httpd.http_request) 52 returns omni_httpd.http_outcome 53 return omni_httpd.http_response(body => 'Hello World'); 54 55 create table my_router (like omni_httpd.urlpattern_router); 56 57 insert into my_router (match, handler) 58 values (omni_httpd.urlpattern('/'), 'my_handler'::regproc); 59 ``` 60 61 After saving the file you can create the application using the command `assemble`. 62 This will build a new database (also called Orb in this context) named first_app using the contents of `first_app/src`. 63 64 65 ```sh 66 omnigres assemble 67 ``` 68 Now check your current endpoints using the `endpoints` command. 69 70 ```sh 71 omnigres endpoints 72 ``` 73 74 The result should be similar to the one below. 75 Note that the IP addresses and ports might differ. 76 77 ```sh 78 omnigres (Postgres): postgres://omnigres:omnigres@172.19.0.3:5432/omnigres 79 omnigres (HTTP): http://172.19.0.3:8081 80 first_app (Postgres): postgres://omnigres:omnigres@172.19.0.3:5432/first_app 81 first_app (HTTP): http://172.19.0.3:8080 82 ``` 83 84 Open the HTTP address in your browser for `first_app`, and you should see the message 'Hello, world!' 85 86 ### Stopping the service 87 88 To stop the service just use the `stop` command. 89 90 ```sh 91 omnigres stop 92 ``` 93 94 ## Compiling from source 95 96 First ensure you have a working [go development environment](https://go.dev/dl/). 97 98 ```sh 99 go build -o omnigres cmd/omnigres/main.go 100 ``` 101 The command above should compile a binary `omnigres` at the project's root folder.