<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package command

import (
	"github.com/fatih/color"
	"github.com/urfave/cli"

	h "github.com/ernestio/ernest-cli/helper"
)

// NullWriter to disable logging
type NullWriter int

// Write sends to nowhere the log messages
func (NullWriter) Write([]byte) (int, error) { return 0, nil }

// MonitorEnv command
// Monitorizes an environment and shows the actions being performed on it
var MonitorEnv = cli.Command{
	Name:        "monitor",
	Aliases:     []string{"m"},
	Usage:       h.T("monitor.usage"),
	ArgsUsage:   h.T("monitor.args"),
	Description: h.T("monitor.description"),
	Action: func(c *cli.Context) error {
		m, cfg := setup(c)
		if cfg.Token == "" {
			color.Red("You're not allowed to perform this action, please log in")
			return nil
		}

		if len(c.Args()) == 0 {
			h.PrintError("You should specify an existing project name")
		}
		if len(c.Args()) == 1 {
			h.PrintError("You should specify an existing env name")
		}
		if len(c.Args()) == 2 {
			h.PrintError("You should specify a build id")
		}

		project := c.Args()[0]
		env := c.Args()[1]
		id := c.Args()[2]
		build, err := m.BuildStatus(cfg.Token, project, env, id)
		if err != nil {
			h.PrintError(err.Error())
		}

		if build.Status == "done" {
			color.Yellow("Environment has been successfully built")
			color.Yellow("You can check its information running `ernest-cli env info " + project + " / " + env + "`")
			return nil
		}

		return h.Monitorize(cfg.URL, "/events", cfg.Token, build.ID)
	},
}
<commit_msg>removing build id requirement from monitor command<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package command

import (
	"github.com/fatih/color"
	"github.com/urfave/cli"

	h "github.com/ernestio/ernest-cli/helper"
)

// NullWriter to disable logging
type NullWriter int

// Write sends to nowhere the log messages
func (NullWriter) Write([]byte) (int, error) { return 0, nil }

// MonitorEnv command
// Monitorizes an environment and shows the actions being performed on it
var MonitorEnv = cli.Command{
	Name:        "monitor",
	Aliases:     []string{"m"},
	Usage:       h.T("monitor.usage"),
	ArgsUsage:   h.T("monitor.args"),
	Description: h.T("monitor.description"),
	Action: func(c *cli.Context) error {
		m, cfg := setup(c)
		if cfg.Token == "" {
			color.Red("You're not allowed to perform this action, please log in")
			return nil
		}

		if len(c.Args()) == 0 {
			h.PrintError("You should specify an existing project name")
		}
		if len(c.Args()) == 1 {
			h.PrintError("You should specify an existing env name")
		}

		project := c.Args()[0]
		env := c.Args()[1]

		id, err := m.LatestBuildID(cfg.Token, project, env)
		if err != nil {
			h.PrintError(err.Error())
		}

		build, err := m.BuildStatus(cfg.Token, project, env, id)
		if err != nil {
			h.PrintError(err.Error())
		}

		if build.Status == "done" {
			color.Yellow("Environment has been successfully built")
			color.Yellow("You can check its information running `ernest-cli env info " + project + " / " + env + "`")
			return nil
		}

		return h.Monitorize(cfg.URL, "/events", cfg.Token, build.ID)
	},
}

{'fraction_non_alphanumeric': 0.14545454545454545, 'fraction_numerical': 0.005772005772005772, 'mean_word_length': 3.300248138957816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2179012', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1138, 'n_words': 368}