github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/docs/v2/framework/cli.md (about) 1 --- 2 title: CLI 3 keywords: cli 4 tags: [cli] 5 sidebar: home_sidebar 6 summary: 7 --- 8 9 # micro cli 10 11 The **micro cli** is a command line interface for the micro toolkit [micro](https://github.com/tickoalcantara12/micro). 12 13 ## Getting Started 14 15 - [Install](#install) 16 - [Interactive Mode](#interactive-mode) 17 - [List Services](#list-services) 18 - [Get Service](#get-service) 19 - [Call Service](#call-service) 20 - [Service Health](#service-health) 21 - [Proxy Remote Environment](#proxy-remote-env) 22 23 ## Install 24 25 ```shell 26 go get github.com/tickoalcantara12/micro/v2 27 ``` 28 29 ## Interactive Mode 30 31 To use the cli as an interactive prompt 32 33 ``` 34 micro cli 35 ``` 36 37 Remove `micro` from the below commands when in interactive mode 38 39 ## Example Usage 40 41 42 ### List Services 43 44 ```shell 45 micro list services 46 ``` 47 48 ### Get Service 49 50 ```shell 51 micro get service go.micro.srv.example 52 ``` 53 54 Output 55 56 ``` 57 go.micro.srv.example 58 59 go.micro.srv.example-fccbb6fb-0301-11e5-9f1f-68a86d0d36b6 [::] 62421 60 ``` 61 62 ### Call Service 63 64 ```shell 65 micro call go.micro.srv.example Example.Call '{"name": "John"}' 66 ``` 67 68 Output 69 ``` 70 { 71 "msg": "go.micro.srv.example-fccbb6fb-0301-11e5-9f1f-68a86d0d36b6: Hello John" 72 } 73 ``` 74 75 ### Service Health 76 77 ```shell 78 micro health go.micro.srv.example 79 ``` 80 81 Output 82 83 ``` 84 node address:port status 85 go.micro.srv.example-fccbb6fb-0301-11e5-9f1f-68a86d0d36b6 [::]:62421 ok 86 ``` 87 88 ### Register/Deregister 89 90 ```shell 91 micro register service '{"name": "foo", "version": "bar", "nodes": [{"id": "foo-1", "address": "127.0.0.1", "port": 8080}]}' 92 ``` 93 94 ```shell 95 micro deregister service '{"name": "foo", "version": "bar", "nodes": [{"id": "foo-1", "address": "127.0.0.1", "port": 8080}]}' 96 ``` 97 98 ## Proxy Remote Env 99 100 Proxy remote environments using the `micro proxy` 101 102 When developing against remote environments you may not have direct access to service discovery 103 which makes it difficult to use the CLI. The `micro proxy` provides a http proxy for such scenarios. 104 105 Run the proxy in your remote environment 106 107 ``` 108 micro proxy 109 ``` 110 111 Set the env var `MICRO_PROXY_ADDRESS` so the cli knows to use the proxy 112 113 ```shell 114 MICRO_PROXY_ADDRESS=staging.micro.mu:8081 micro list services 115 ``` 116 117 ## Usage 118 119 ```shell 120 NAME: 121 micro - A cloud-native toolkit 122 123 USAGE: 124 micro [global options] command [command options] [arguments...] 125 126 VERSION: 127 0.8.0 128 129 COMMANDS: 130 api Run the micro API 131 bot Run the micro bot 132 registry Query registry 133 call Call a service or function 134 query Deprecated: Use call instead 135 stream Create a service or function stream 136 health Query the health of a service 137 stats Query the stats of a service 138 list List items in registry 139 register Register an item in the registry 140 deregister Deregister an item in the registry 141 get Get item from registry 142 proxy Run the micro proxy 143 new Create a new micro service by specifying a directory path relative to your $GOPATH 144 web Run the micro web app 145 ``` 146