Usage:"initialize a new compliance repository (interactive)",
Action:initAction,
}
funcinitAction(c*cli.Context)error{
fi,_:=ioutil.ReadDir(config.ProjectRoot())
iflen(fi)>0{
returnerrors.New("init must be run from an empty directory")
}
atLeast:=func(nint)func(string)error{
returnfunc(inputstring)error{
iflen(input)<n{
returnerrors.New("Too short")
}
returnnil
}
}
noSpaces:=func(sstring)error{
ifstrings.ContainsAny(s,"\n\t "){
returnerrors.New("Must not contain spaces")
}
returnnil
}
prompt:=promptui.Prompt{
Label:"Organization Name",
Validate:atLeast(1),
}
name,err:=prompt.Run()
iferr!=nil{
fmt.Printf("Prompt failed %v\n",err)
returnerr
}
prompt=promptui.Prompt{
Label:"PDF Filename Prefix (no spaces, no trailing separator)",
Default:strings.Split(name," ")[0],
Validate:noSpaces,
}
prefix,err:=prompt.Run()
iferr!=nil{
fmt.Printf("Prompt failed %v\n",err)
returnerr
}
chooser:=promptui.Select{
Label:"Compliance Templates",
Items:[]string{"SOC2","Blank"},
}
choice,_,err:=chooser.Run()
iferr!=nil{
fmt.Printf("Prompt failed %v\n",err)
returnerr
}
themeName:="comply-blank"
switchchoice{
case0:
themeName="comply-soc2"
case1:
themeName="comply-blank"
default:
panic("unrecognized selection")
}
fmt.Printf("\nComply relies on your ticketing system for optional procedure tracking. You can always come back and enable this integration later.\n\n\n")