blob: a20fbf46c8863cab274120f43a553832b49cdd1f [file] [log] [blame]
Don Newton2bdfd3f2019-04-08 17:06:33 -04001/*
2 * Copyright 2018-present Open Networking Foundation
3
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
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
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*/
16
17package main
18
19import (
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
29func 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}
55func printHeader() {
56 header :=
57 ` _ _ _ ___ _ ___
58__ _____| | |_| |_ __ _ / __| | |_ _|
59\ V / _ \ | _| ' \/ _' | | (__| |__ | |
60 \_/\___/_|\__|_||_\__,_| \___|____|___|
61`
62 fmt.Println(header)
63}