func runMfgHashableCmd()

in cli/mfg_cmds.go [324:354]


func runMfgHashableCmd(cmd *cobra.Command, args []string) {
	if len(args) < 1 {
		ImgmodUsage(cmd, nil)
	}

	if OptOutFilename == "" {
		ImgmodUsage(cmd, errors.Errorf("--outfile (-o) option required"))
	}

	mfgDir := args[0]
	outFilename := OptOutFilename

	m, man, err := readMfgDir(mfgDir)
	if err != nil {
		ImgmodUsage(cmd, err)
	}

	// Zero-out hash so that the hash can be recalculated.
	if m.Meta != nil {
		m.Meta.ClearHash()
	}

	// Write hashable content to disk.
	newBin, err := m.Bytes(man.EraseVal)
	if err != nil {
		ImgmodUsage(nil, err)
	}
	if err := WriteFile(newBin, outFilename); err != nil {
		ImgmodUsage(nil, err)
	}
}