Repository: hasura/graphql-engine
File: cli/commands/init.go (Go)

Code before:
	Endpoint    string
	AdminSecret string
	InitDir     string

	Template string
}

func (o *InitOptions) Run() error {
	var infoMsg string
	// prompt for init directory if it's not set already
	if o.InitDir == "" {
		p := promptui.Prompt{
			Label:   "Name of project directory ",
			Default: defaultDirectory,
		}
		r, err := p.Run()
		if err != nil {
			return handlePromptError(err)
		}
		if strings.TrimSpace(r) != "" {
			o.InitDir = r
		} else {
			o.InitDir = defaultDirectory
		}
	}
	if o.InitDir == "." {
		dir, err := os.Getwd()
		if err != nil {
			return errors.Wrap(err, "error getting current working directory")
		}
		// check if pwd is filesystem root
		if err := cli.CheckFilesystemBoundary(dir); err != nil {
			return errors.Wrap(err, "can't initialise hasura project in filesystem root")
		}
		// check if the current directory is already a hasura project
		if err := cli.ValidateDirectory(dir); err == nil {
			return errors.Errorf("current working directory is already a hasura project directory")
		}
		o.EC.ExecutionDirectory = dir
		infoMsg = fmt.Sprintf(`hasura project initialised. execute the following command to continue:
  hasura console
`)
	} else {
		// create execution directory
		err := o.createExecutionDirectory()
		if err != nil {
			return err
		}
		infoMsg = fmt.Sprintf(`directory created. execute the following commands to continue:

  cd %s

Review comment (suggestion):
@ShraddhaAg a nitpick, 
Instead of directly comparing to `.` do you think something similar to the following is better?
```
	cwdir, err := os.Getwd()
	if err != nil {
		return errors.Wrap(err, "error getting current working directory")
	}
	initPath, err := filepath.Abs(o.InitDir)
	if err != nil {
		return err
	}
	if initPath == cwdir {
             // do stuff
        }
```
This can also handle paths like `./`

Code after:
	Endpoint    string
	AdminSecret string
	InitDir     string

	Template string
}

func (o *InitOptions) Run() error {
	var infoMsg string
	// prompt for init directory if it's not set already
	if o.InitDir == "" {
		p := promptui.Prompt{
			Label:   "Name of project directory ",
			Default: defaultDirectory,
		}
		r, err := p.Run()
		if err != nil {
			return handlePromptError(err)
		}
		if strings.TrimSpace(r) != "" {
			o.InitDir = r
		} else {
			o.InitDir = defaultDirectory
		}
	}

	cwdir, err := os.Getwd()
	if err != nil {
		return errors.Wrap(err, "error getting current working directory")
	}
	initPath, err := filepath.Abs(o.InitDir)
	if err != nil {
		return err
	}
	if initPath == cwdir {
		// check if pwd is filesystem root
		if err := cli.CheckFilesystemBoundary(cwdir); err != nil {
			return errors.Wrap(err, "can't initialise hasura project in filesystem root")
		}
		// check if the current directory is already a hasura project
		if err := cli.ValidateDirectory(cwdir); err == nil {
			return errors.Errorf("current working directory is already a hasura project directory")
		}
		o.EC.ExecutionDirectory = cwdir
		infoMsg = fmt.Sprintf(`hasura project initialised. execute the following command to continue:
  hasura console
`)
	} else {
		// create execution directory
		err := o.createExecutionDirectory()
		if err != nil {