@@ -9,20 +9,21 @@ import (
99)
1010
1111var (
12- targetURL string
1312 outputFile string
1413 certIndexes []int
1514 version string
1615)
1716
1817// rootCmd represents the base command when called without any subcommands
1918var rootCmd = & cobra.Command {
20- Version : version ,
21- Use : "cert-fetcher" ,
22- Short : "Fetch client certificates from https urls" ,
23- Long : "A go application that fetches public certificates from https sites and stores them into different output formates." ,
19+ Version : version ,
20+ Use : "cert-fetcher [url]" ,
21+ Short : "Fetch client certificates from https urls" ,
22+ Long : "A go application that fetches public certificates from https sites and stores them into different output formats." ,
23+ ValidArgs : []string {"url" },
24+ Args : cobra .ExactArgs (1 ),
2425 RunE : func (cmd * cobra.Command , args []string ) error {
25- return cert .Print (targetURL )
26+ return cert .Print (args [ 0 ] )
2627 },
2728}
2829
@@ -36,8 +37,6 @@ func Execute() {
3637}
3738
3839func init () {
39- rootCmd .PersistentFlags ().StringVarP (& targetURL , "url" , "u" , "" , "the URL to fetch the certificate from" )
40- _ = rootCmd .MarkPersistentFlagRequired ("url" )
4140 rootCmd .PersistentFlags ().StringVarP (& outputFile , "out-file" , "o" , "" , "the output file" )
4241 rootCmd .PersistentFlags ().IntSliceVarP (& certIndexes , "import-at" , "i" , make ([]int , 0 ), "import the certificates at the given indexes" )
4342}
0 commit comments