<commit_before>package crit

import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"os"
)

// CritSvc is the interface that wraps all CRIT operations.
// To create a CRIT service instance, use New().
type CritSvc interface {
	// Read binary image file into Go struct (decode.go)
	Decode() (*CriuImage, error)
	// Read only counts of image file entries into Go struct
	Info() (*CriuImage, error)
	// Read JSON into Go struct
	Parse() (*CriuImage, error)
	// Write JSON to binary image file (encode.go)
	Encode(*CriuImage) error
	// Explore process information (explore.go)
	ExplorePs() (*PsTree, error)
	ExploreFds() ([]*Fd, error)
	ExploreMems() ([]*MemMap, error)
	ExploreRss() ([]*RssMap, error)
}

// crit implements the CritSvc interface. It contains:
// * Path of the input file
// * Path of the output file
// * Path of the input directory (for `crit explore`)
// * Boolean to provide indented and multi-line JSON output
// * Boolean to skip payload data
// * Boolean to indicate CLI usage
type crit struct {
	inputFilePath  string
	outputFilePath string
	// Directory path is required only for exploring
	inputDirPath string
	pretty       bool
	noPayload    bool
	cli          bool
}

// New creates a CRIT service to use in a Go program
func New(
	inputFilePath, outputFilePath,
	inputDirPath string,
	pretty, noPayload bool,
) CritSvc {
	return &crit{
		inputFilePath:  inputFilePath,
		outputFilePath: outputFilePath,
		inputDirPath:   inputDirPath,
		pretty:         pretty,
		noPayload:      noPayload,
		cli:            false,
	}
}

// NewCli creates a CRIT service to use in a CLI app.
// All functions called by this service will wait for<commit_msg>docs(crit): Improve description for pretty flag<commit_after>package crit

import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"os"
)

// CritSvc is the interface that wraps all CRIT operations.
// To create a CRIT service instance, use New().
type CritSvc interface {
	// Read binary image file into Go struct (decode.go)
	Decode() (*CriuImage, error)
	// Read only counts of image file entries into Go struct
	Info() (*CriuImage, error)
	// Read JSON into Go struct
	Parse() (*CriuImage, error)
	// Write JSON to binary image file (encode.go)
	Encode(*CriuImage) error
	// Explore process information (explore.go)
	ExplorePs() (*PsTree, error)
	ExploreFds() ([]*Fd, error)
	ExploreMems() ([]*MemMap, error)
	ExploreRss() ([]*RssMap, error)
}

// crit implements the CritSvc interface. It contains:
// * Path of the input file
// * Path of the output file
// * Path of the input directory (for `crit explore`)
// * Boolean to format and indent JSON output
// * Boolean to skip payload data
// * Boolean to indicate CLI usage
type crit struct {
	inputFilePath  string
	outputFilePath string
	// Directory path is required only for exploring
	inputDirPath string
	pretty       bool
	noPayload    bool
	cli          bool
}

// New creates a CRIT service to use in a Go program
func New(
	inputFilePath, outputFilePath,
	inputDirPath string,
	pretty, noPayload bool,
) CritSvc {
	return &crit{
		inputFilePath:  inputFilePath,
		outputFilePath: outputFilePath,
		inputDirPath:   inputDirPath,
		pretty:         pretty,
		noPayload:      noPayload,
		cli:            false,
	}
}

// NewCli creates a CRIT service to use in a CLI app.
// All functions called by this service will wait for
{'fraction_non_alphanumeric': 0.09575104727707959, 'fraction_numerical': 0.0, 'mean_word_length': 3.421957671957672, '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': '5232877', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1018, 'n_words': 413}