-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add trial command to get a DXP trial key
- Loading branch information
Showing
5 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
layout: default | ||
title: trial | ||
parent: Commands | ||
nav_order: 11 | ||
permalink: /cmd/trial | ||
--- | ||
|
||
# lfr trial | ||
{: .d-inline-block } | ||
NEW (3.2.0) | ||
{: .label .label-green .mb-5 } | ||
|
||
|
||
It will fetch a DXP trial key from [this repo](https://github.com/lgdd/liferay-product-info/tree/main/dxp-trial) which automatically extract a DXP trial key from the latest Docker image of Liferay DXP. | ||
|
||
The DXP trial key is then saved in the current directory of the command as a `trial.xml` file. If this file already exists, it won't override it. | ||
|
||
## Usage: | ||
```shell | ||
lfr trial | ||
lfr t | ||
``` | ||
|
||
## Flags: | ||
- `-h`, `--help` | ||
- help for `lfr trial` | ||
## Global Flags: | ||
- `--no-color` | ||
- disable colors for output messages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package trial | ||
|
||
import ( | ||
"io" | ||
"net/http" | ||
"os" | ||
|
||
"github.com/lgdd/lfr-cli/internal/conf" | ||
"github.com/lgdd/lfr-cli/pkg/util/logger" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
Cmd = &cobra.Command{ | ||
Use: "trial", | ||
Aliases: []string{"t"}, | ||
Short: "Get a DXP trial key to be placed in the current directory", | ||
Args: cobra.NoArgs, | ||
Run: run, | ||
} | ||
Follow bool | ||
) | ||
|
||
func init() { | ||
conf.Init() | ||
} | ||
|
||
func run(cmd *cobra.Command, args []string) { | ||
resp, error := http.Get("https://raw.githubusercontent.com/lgdd/liferay-product-info/refs/heads/main/dxp-trial/trial.xml") | ||
|
||
if error != nil { | ||
logger.Fatal(error.Error()) | ||
} | ||
|
||
defer resp.Body.Close() | ||
body, _ := io.ReadAll(resp.Body) | ||
if _, error = os.Stat("trial.xml"); error == nil { | ||
logger.PrintWarn("trial.xml already exists") | ||
} else { | ||
os.WriteFile("trial.xml", body, 0666) | ||
logger.PrintSuccess("created ") | ||
logger.Print("trial.xml") | ||
} | ||
} |