Exemplo n.º 1
0
func (lsc lsCmd) collectPath(w io.Writer, r io.Reader, ls *semantic.LogicState) {
	fmt.Fprintf(w, "\n\nEditing Path\nCurrent Value: %q\n", ls.Path)
	fmt.Fprint(w, "\nNew value: ")

	scn := bufio.NewScanner(r)
	for {
		scn.Scan()
		path := scn.Text()

		f, err := os.Open(filepath.Clean(path))
		if err == nil {
			ls.Path = f.Name()

			stat, _ := f.Stat()
			if stat.IsDir() {
				ls.Type = "code"
			} else if strings.HasSuffix(f.Name(), ".so") {
				ls.Type = "library"
			} else {
				ls.Type = "binary"
			}

			break
		} else {
			fmt.Fprintf(w, "\n%s does not exist.\n\nNew value: ", path)
		}
	}
}
Exemplo n.º 2
0
func (lsc lsCmd) collectType(w io.Writer, r io.Reader, ls *semantic.LogicState) {
	fmt.Fprintf(w, "\n\nEditing Logical group\nCurrent Value: %q\n", ls.Type)
	fmt.Fprint(w, "\nNew value: ")

	scn := bufio.NewScanner(r)
	scn.Scan()
	ls.Type = scn.Text()
}