Skip to content

Commit

Permalink
Adding mkdocs changes, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lovestaco committed Jul 22, 2023
1 parent a8bcbed commit e204fd1
Show file tree
Hide file tree
Showing 43 changed files with 970 additions and 508 deletions.
File renamed without changes
2 changes: 1 addition & 1 deletion docs/Lama2/docs/explanation/l2format.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ The local variable's value is taken into consideration regardless of both files

Get [Source Files](https://github.com/HexmosTech/Lama2/tree/main/examples/0020_override_project_root_local)

![Override of l2config.env with l2.env variable](image.png)
![Override of l2config.env with l2.env variable](l2envOverideL2config.png)


#### The environment file can load results of commands
Expand Down
22 changes: 12 additions & 10 deletions docs/Lama2/docs/reference/cmdexec.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,46 @@ Package \`cmdexec\` provides a facility to execute l2 commands, stream output to

## Index

- [func ExecCommand(cmdSlice []string, stdinBody string, apiDir string) (httpie.ExResponse, error)](<#func-execcommand>)
- [func GenerateChainCode(httpRespBody string) string](<#func-generatechaincode>)
- [func GetJSVm() *goja.Runtime](<#func-getjsvm>)
- [func RunVMCode(jsCode string, vm *goja.Runtime)](<#func-runvmcode>)
- [func ExecCommand\(cmdSlice \[\]string, stdinBody string, apiDir string\) \(httpie.ExResponse, error\)](<#ExecCommand>)
- [func GenerateChainCode\(httpRespBody string\) string](<#GenerateChainCode>)
- [func GetJSVm\(\) \*goja.Runtime](<#GetJSVm>)
- [func RunVMCode\(jsCode string, vm \*goja.Runtime\)](<#RunVMCode>)


## func [ExecCommand](<https://github.com/HexmosTech/Lama2/blob/master/cmdexec/cmdexec.go#L23>)
<a name="ExecCommand"></a>
## func [ExecCommand](<https://github.com/HexmosTech/Lama2/blob/main/cmdexec/cmdexec.go#L23>)

```go
func ExecCommand(cmdSlice []string, stdinBody string, apiDir string) (httpie.ExResponse, error)
```

ExecCommand changes directory to the given \`apiDir\` and then executes the command specified in \`cmdStr\` During command execution, ExecCommand streams output to stdout. Once execution finishes, previous CWD is restored, and the command output is returned as a string

## func [GenerateChainCode](<https://github.com/HexmosTech/Lama2/blob/master/cmdexec/js.go#L39>)
<a name="GenerateChainCode"></a>
## func [GenerateChainCode](<https://github.com/HexmosTech/Lama2/blob/main/cmdexec/js.go#L39>)

```go
func GenerateChainCode(httpRespBody string) string
```

GenerateChainCode takes in an HTTP response body and comes up with some JS code to define the "magic variable" result. What does the code do? The result is stored as a JS object, if the input value can be parsed as JSON. Otherwise the value is stored as a simple string.

## func [GetJSVm](<https://github.com/HexmosTech/Lama2/blob/master/cmdexec/js.go#L12>)
<a name="GetJSVm"></a>
## func [GetJSVm](<https://github.com/HexmosTech/Lama2/blob/main/cmdexec/js.go#L12>)

```go
func GetJSVm() *goja.Runtime
```

GetJSVm creates a new goja runtime instance with console.log enabled

## func [RunVMCode](<https://github.com/HexmosTech/Lama2/blob/master/cmdexec/js.go#L26>)
<a name="RunVMCode"></a>
## func [RunVMCode](<https://github.com/HexmosTech/Lama2/blob/main/cmdexec/js.go#L26>)

```go
func RunVMCode(jsCode string, vm *goja.Runtime)
```

RunVMCode takes in a JS snippet as a string, executes the code in a JS VM, finally checks whether there are any errors, and if yes, logs the problem. Note: the vm runtime remains modified; so if you reuse the vm for other operations, the state from previous invocations carry over



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
7 changes: 3 additions & 4 deletions docs/Lama2/docs/reference/cmdgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ Package \`cmdgen\` provides an API to generate API request commands \(by default

## Index

- [func ConstructCommand(parsedInput *gabs.Container, o *lama2cmd.Opts) ([]string, string)](<#func-constructcommand>)
- [func ConstructCommand\(parsedInput \*gabs.Container, o \*lama2cmd.Opts\) \(\[\]string, string\)](<#ConstructCommand>)


## func [ConstructCommand](<https://github.com/HexmosTech/Lama2/blob/master/cmdgen/cmdgen.go#L99>)
<a name="ConstructCommand"></a>
## func [ConstructCommand](<https://github.com/HexmosTech/Lama2/blob/main/cmdgen/cmdgen.go#L99>)

```go
func ConstructCommand(parsedInput *gabs.Container, o *lama2cmd.Opts) ([]string, string)
```

ConstructCommand extracts the HTTP verb, url and other API file inputs, figures out the type of target command and finally generates a string representing the generated command



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
35 changes: 23 additions & 12 deletions docs/Lama2/docs/reference/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,56 @@ Package controller coordinates all the other components in the \`Lama2\` project

## Index

- [func ExecuteProcessorBlock(block *gabs.Container, vm *goja.Runtime)](<#func-executeprocessorblock>)
- [func ExecuteRequestorBlock(block *gabs.Container, vm *goja.Runtime, opts *lama2cmd.Opts, dir string) httpie.ExResponse](<#func-executerequestorblock>)
- [func GetParsedAPIBlocks(parsedAPI *gabs.Container) []*gabs.Container](<#func-getparsedapiblocks>)
- [func HandleParsedFile(parsedAPI *gabs.Container, o *lama2cmd.Opts, dir string)](<#func-handleparsedfile>)
- [func Process(version string)](<#func-process>)
- [func ExecuteProcessorBlock\(block \*gabs.Container, vm \*goja.Runtime\)](<#ExecuteProcessorBlock>)
- [func ExecuteRequestorBlock\(block \*gabs.Container, vm \*goja.Runtime, opts \*lama2cmd.Opts, dir string\) httpie.ExResponse](<#ExecuteRequestorBlock>)
- [func GetParsedAPIBlocks\(parsedAPI \*gabs.Container\) \[\]\*gabs.Container](<#GetParsedAPIBlocks>)
- [func HandleParsedFile\(parsedAPI \*gabs.Container, o \*lama2cmd.Opts, dir string\)](<#HandleParsedFile>)
- [func Process\(version string\)](<#Process>)


## func [ExecuteProcessorBlock](<https://github.com/HexmosTech/Lama2/blob/master/controller/controller.go#L31>)
<a name="ExecuteProcessorBlock"></a>
## func [ExecuteProcessorBlock](<https://github.com/HexmosTech/Lama2/blob/main/controller/controller.go#L30>)

```go
func ExecuteProcessorBlock(block *gabs.Container, vm *goja.Runtime)
```

## func [ExecuteRequestorBlock](<https://github.com/HexmosTech/Lama2/blob/master/controller/controller.go#L38>)


<a name="ExecuteRequestorBlock"></a>
## func [ExecuteRequestorBlock](<https://github.com/HexmosTech/Lama2/blob/main/controller/controller.go#L37>)

```go
func ExecuteRequestorBlock(block *gabs.Container, vm *goja.Runtime, opts *lama2cmd.Opts, dir string) httpie.ExResponse
```

## func [GetParsedAPIBlocks](<https://github.com/HexmosTech/Lama2/blob/master/controller/controller.go#L27>)


<a name="GetParsedAPIBlocks"></a>
## func [GetParsedAPIBlocks](<https://github.com/HexmosTech/Lama2/blob/main/controller/controller.go#L26>)

```go
func GetParsedAPIBlocks(parsedAPI *gabs.Container) []*gabs.Container
```

## func [HandleParsedFile](<https://github.com/HexmosTech/Lama2/blob/master/controller/controller.go#L55>)


<a name="HandleParsedFile"></a>
## func [HandleParsedFile](<https://github.com/HexmosTech/Lama2/blob/main/controller/controller.go#L54>)

```go
func HandleParsedFile(parsedAPI *gabs.Container, o *lama2cmd.Opts, dir string)
```

## func [Process](<https://github.com/HexmosTech/Lama2/blob/master/controller/controller.go#L83>)


<a name="Process"></a>
## func [Process](<https://github.com/HexmosTech/Lama2/blob/main/controller/controller.go#L81>)

```go
func Process(version string)
```

Process initiates the following tasks in the given order: 1. Parse command line arguments 2. Read API file contents 3. Expand environment variables in API file 4. Parse the API contents 5. Generate API request command 6. Execute command & retrieve results 7. Optionally, post\-process and write results to a JSON file



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
20 changes: 12 additions & 8 deletions docs/Lama2/docs/reference/lama2cmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ Package \`lama2cmd\` provides CLI argument parsing facilities. It hosts the \`Op

## Index

- [func ArgParsing(o *Opts, version string)](<#func-argparsing>)
- [type Opts](<#type-opts>)
- [func GetAndValidateCmd(ipArgs []string) *Opts](<#func-getandvalidatecmd>)
- [func ArgParsing\(o \*Opts, version string\)](<#ArgParsing>)
- [type Opts](<#Opts>)
- [func GetAndValidateCmd\(ipArgs \[\]string\) \*Opts](<#GetAndValidateCmd>)


## func [ArgParsing](<https://github.com/HexmosTech/Lama2/blob/master/lama2cmd/lama2cmd.go#L79>)
<a name="ArgParsing"></a>
## func [ArgParsing](<https://github.com/HexmosTech/Lama2/blob/main/lama2cmd/lama2cmd.go#L80>)

```go
func ArgParsing(o *Opts, version string)
```

## type [Opts](<https://github.com/HexmosTech/Lama2/blob/master/lama2cmd/lama2cmd.go#L18-L34>)


<a name="Opts"></a>
## type [Opts](<https://github.com/HexmosTech/Lama2/blob/main/lama2cmd/lama2cmd.go#L18-L35>)

The Opts structure stores user preferences, and is used throughout the module to make various decisions.

Expand All @@ -37,6 +41,7 @@ type Opts struct {
PostmanFile string `short:"p" long:"postmanfile" description:"JSON export from Postman (Settings -> Data -> Export Data)"`
LamaDir string `short:"l" long:"lama2dir" description:"Output directory to put .l2 files after conversion from Postman format"`
Help bool `short:"h" long:"help" group:"AddHelp" description:"Usage help for Lama2"`
Env bool `short:"e" long:"env" description:"Get a JSON of environment variables"`
Version bool `long:"version" description:"Print Lama2 binary version"`

Positional struct {
Expand All @@ -45,14 +50,13 @@ type Opts struct {
}
```

### func [GetAndValidateCmd](<https://github.com/HexmosTech/Lama2/blob/master/lama2cmd/lama2cmd.go#L112>)
<a name="GetAndValidateCmd"></a>
### func [GetAndValidateCmd](<https://github.com/HexmosTech/Lama2/blob/main/lama2cmd/lama2cmd.go#L112>)

```go
func GetAndValidateCmd(ipArgs []string) *Opts
```

GetAndValidateCmd takes in the user's CLI input, and checks for validity. If not OK, displays a help message in stdout. Otherwise, fills the Opts structure and returns it Moreover, based on user input, the outputManager gets configured \(whether user prefers trace/debug/info level\)



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
21 changes: 12 additions & 9 deletions docs/Lama2/docs/reference/outputmanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,44 @@ Package \`outputmanager\` provides facilities for controlling the logging librar
## Index

- [Variables](<#variables>)
- [func ConfigureZeroLog(level string)](<#func-configurezerolog>)
- [func ResponseToJSON(resp httpie.ExResponse) (*gabs.Container, error)](<#func-responsetojson>)
- [func WriteJSONOutput(resp httpie.ExResponse, targetPath string)](<#func-writejsonoutput>)
- [func ConfigureZeroLog\(level string\)](<#ConfigureZeroLog>)
- [func ResponseToJSON\(resp httpie.ExResponse\) \(\*gabs.Container, error\)](<#ResponseToJSON>)
- [func WriteJSONOutput\(resp httpie.ExResponse, targetPath string\)](<#WriteJSONOutput>)


## Variables

LogBuff is used to append various log statements into memory. If the user toggles the \`Output \(\-o\)\` option, then the contents of LogBuff is pushed into a JSON file
<a name="LogBuff"></a>LogBuff is used to append various log statements into memory. If the user toggles the \`Output \(\-o\)\` option, then the contents of LogBuff is pushed into a JSON file

```go
var LogBuff bytes.Buffer
```

## func [ConfigureZeroLog](<https://github.com/HexmosTech/Lama2/blob/master/outputManager/output_manager.go#L33>)
<a name="ConfigureZeroLog"></a>
## func [ConfigureZeroLog](<https://github.com/HexmosTech/Lama2/blob/main/outputManager/output_manager.go#L33>)

```go
func ConfigureZeroLog(level string)
```

ConfigureZeroLog provides global log level setting. By default, ZeroLog uses the DEBUG level; however, the function makes the desired level more explicit

## func [ResponseToJSON](<https://github.com/HexmosTech/Lama2/blob/master/outputManager/output_manager.go#L49>)
<a name="ResponseToJSON"></a>
## func [ResponseToJSON](<https://github.com/HexmosTech/Lama2/blob/main/outputManager/output_manager.go#L49>)

```go
func ResponseToJSON(resp httpie.ExResponse) (*gabs.Container, error)
```

## func [WriteJSONOutput](<https://github.com/HexmosTech/Lama2/blob/master/outputManager/output_manager.go#L70>)


<a name="WriteJSONOutput"></a>
## func [WriteJSONOutput](<https://github.com/HexmosTech/Lama2/blob/main/outputManager/output_manager.go#L70>)

```go
func WriteJSONOutput(resp httpie.ExResponse, targetPath string)
```

WriteJSONOutput is primarily built for helping with Extension/Integration building with external tools. Extension writers may simply call \`l2 \-n \-o /tmp/lama2.json ...\` to invoke WriteJSONOutput; the generated json file contains three keys: \`logs\`, \`headers\`, \`body\`



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
Loading

0 comments on commit e204fd1

Please sign in to comment.