Don Newton | 2bdfd3f | 2019-04-08 17:06:33 -0400 | [diff] [blame] | 1 | /* |
Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Don Newton | 2bdfd3f | 2019-04-08 17:06:33 -0400 | [diff] [blame] | 3 | |
Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Don Newton | 2bdfd3f | 2019-04-08 17:06:33 -0400 | [diff] [blame] | 7 | |
Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Don Newton | 2bdfd3f | 2019-04-08 17:06:33 -0400 | [diff] [blame] | 9 | |
Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Don Newton | 2bdfd3f | 2019-04-08 17:06:33 -0400 | [diff] [blame] | 16 | |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 20 | "flag" |
| 21 | "fmt" |
| 22 | "log" |
| 23 | "os/exec" |
| 24 | |
| 25 | "github.com/opencord/voltha-go/cli/menu/mainmenu" |
| 26 | "google.golang.org/grpc" |
| 27 | ) |
| 28 | |
| 29 | func main() { |
| 30 | |
| 31 | // disable input buffering |
| 32 | exec.Command("stty", "-F", "/dev/tty", "cbreak", "min", "1").Run() |
| 33 | // do not display entered characters on the screen |
| 34 | exec.Command("stty", "-F", "/dev/tty", "-echo").Run() |
| 35 | printHeader() |
| 36 | |
| 37 | volthaAddress := flag.String("voltha_address", "localhost:6161", "IP/Hostname:Port for Voltha Core") |
| 38 | h := flag.Bool("h", false, "Print help") |
| 39 | help := flag.Bool("help", false, "Print help") |
| 40 | flag.Parse() |
| 41 | if *h || *help { |
| 42 | fmt.Println("cli -h(elp) print this message") |
| 43 | fmt.Println("cli -voltha_address=$VOLTHA_ADDRESS:PORT default localhost:6161") |
| 44 | return |
| 45 | } |
| 46 | conn, err := grpc.Dial(*volthaAddress, grpc.WithInsecure()) |
| 47 | if err != nil { |
| 48 | log.Fatalf("did not connect: %s", err) |
| 49 | } |
| 50 | defer conn.Close() |
| 51 | fmt.Println("Connecting to " + *volthaAddress) |
| 52 | |
| 53 | mainmenu.MainLoop(conn) |
| 54 | } |
| 55 | func printHeader() { |
| 56 | header := |
| 57 | ` _ _ _ ___ _ ___ |
| 58 | __ _____| | |_| |_ __ _ / __| | |_ _| |
| 59 | \ V / _ \ | _| ' \/ _' | | (__| |__ | | |
| 60 | \_/\___/_|\__|_||_\__,_| \___|____|___| |
| 61 | ` |
| 62 | fmt.Println(header) |
| 63 | } |