github.com/LGUG2Z/story@v0.4.1/cli/blast_radius.go (about)

     1  package cli
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/LGUG2Z/story/manifest"
     7  	"github.com/spf13/afero"
     8  	"github.com/urfave/cli"
     9  )
    10  
    11  func BlastRadiusCmd(fs afero.Fs) cli.Command {
    12  	return cli.Command{
    13  		Name:  "blastradius",
    14  		Usage: "Shows a list of current story's blast radius",
    15  		Action: func(c *cli.Context) error {
    16  			if !isStory {
    17  				return ErrNotWorkingOnAStory
    18  			}
    19  
    20  			if c.Args().Present() {
    21  				return ErrCommandTakesNoArguments
    22  			}
    23  
    24  			story, err := manifest.LoadStory(fs)
    25  			if err != nil {
    26  				return err
    27  			}
    28  
    29  			var brMap = make(map[string]bool)
    30  
    31  			for _, br := range story.BlastRadius {
    32  				for _, p := range br {
    33  					if !brMap[p] {
    34  						brMap[p] = true
    35  					}
    36  				}
    37  			}
    38  
    39  			for project := range brMap {
    40  				fmt.Println(project)
    41  			}
    42  
    43  			return nil
    44  		},
    45  	}
    46  }