Skip to content
Snippets Groups Projects
main.go 1.31 KiB
Newer Older
/*
 * Copyright (C) 2022 Associated Universities, Inc. Washington DC, USA.
 *
 * This file is part of NRAO Workspaces.
 *
 * Workspaces is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Workspaces is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Workspaces.  If not, see <https://www.gnu.org/licenses/>.
 */
	"encoding/json"
	"flag"
	"fmt"
	"os"
	wrest "ssa/contacts_wrest/pkg/contacts_wrest"
	"strings"
	jsonMode := flag.Bool("j", false, "Output a JSON-friendly list of strings instead of human-friendly list")

	// Parse the CLI arguments
	flag.Parse()

	if flag.NArg() != 1 {
		fmt.Printf("Usage: %v [-j] <PROJECT-CODE>", os.Args[0])
		os.Exit(1)
	}

	contacts := wrest.RetrieveContacts(flag.Arg(0))

	if *jsonMode {
		binary, _ := json.Marshal(contacts)
		fmt.Println(string(binary))
	} else {
		fmt.Println(strings.Join(contacts, ", "))
	}