Skip to content

Commit

Permalink
Add README and code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethnym committed Feb 12, 2024
1 parent 791d8c9 commit bd206c2
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 10 deletions.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Poly CLI

[What is Poly?](https://polygui.org)

This CLI provides commands to create and manage Poly projects. It is the official way to get started with creating Poly
applications.

## Installation

The CLI is available as pre-built binaries on the [GitHub Releases page](https://github.com/poly-gui/cli/releases).

### Building The CLI

The CLI can also be built from the source code, which requires:

- [Go >= 1.20](https://go.dev/dl/)

First, clone this repo:

```
git clone https://github.com/poly-gui/cli.git
```

This clones the repo into a directory called "cli". If the name is too generic, feel free to clone the repo into a
directory with a different name.

Change into the repo, then build and install the binary:

```
go install poly-cli/cmd/poly
```

The `poly` command should now be installed and ready to use. Make sure `GOBIN`
is in PATH, which defaults to `$(go env GOPATH)/bin`. If not, add:

```
export PATH="$PATH:$(go env GOPATH)/bin"
```

or if `GOBIN` is set:

```
export PATH="$PATH:$(go env GOBIN)/bin"
```

to your path.

For more information on `GOPATH` and `GOBIN`, please consult
the [official documentation](https://go.dev/doc/install/source#gopath).

## Usage

### ```poly generate```

The `generate` command creates a new Poly project directory in the current working directory by default. The following
flags are available:

| Flags | Description |
|:-----------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------:|
| `--output` | The directory in which the project directory should be created. Defaults to the current working directory. |
| `--name` | The name of the application. Defaults to "PolyApp" |
| `--package` | The package name/bundle identifier/application ID of the application. This typically uses the reverse domain name notation. Defaults to "org.polygui" |

### Examples

```
poly generate --name=MyNewApp --package=org.my
```

This generates a new Poly app called "MyNewApp" that has "org.my" as the package identifier. A "MyNewApp" directory is created in the current working directory.
2 changes: 2 additions & 0 deletions internal/cli/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package cli contains the main logic of the CLI.
package cli
1 change: 1 addition & 0 deletions internal/cli/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sync"
)

// Generate is run when `poly generate` is invoked.
func Generate() error {
os.Args = append(os.Args[:1], os.Args[2:]...)

Expand Down
1 change: 1 addition & 0 deletions internal/template/appkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package template

import "path/filepath"

// AppKitSourceFiles is a list of templates of files that will be in the "macOS" directory in a Poly project.
var AppKitSourceFiles = []templateFile{XcodeGenSpec, SwiftMainFile, AppDelegate}

var XcodeGenSpec = templateFile{
Expand Down
10 changes: 0 additions & 10 deletions internal/template/funcmap.go

This file was deleted.

1 change: 1 addition & 0 deletions internal/template/gtk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package template

import "path/filepath"

// GTKSourceFiles is a list of templates of files that will be in the "gtk" directory in a Poly project.
var GTKSourceFiles = []templateFile{GTKCMakeLists, GTKCxxMainFile, GTKLaunchScript, GTKRPMSpec}

var GTKCMakeLists = templateFile{
Expand Down
2 changes: 2 additions & 0 deletions internal/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
gotemplate "text/template"
)

// templateFile describes the template for a file that is generated during the creation of a new Poly project.
type templateFile struct {
// FilePathRel is the path to the output file relative to the native source code directory such as <project>/macOS or <project>/gtk.
// Use _APP_NAME_ as a placeholder for the app name if needed.
Expand All @@ -24,6 +25,7 @@ type templateFile struct {
TemplateName string
}

// funcMap defines functions that are usable in templateFile.template.
var funcMap = gotemplate.FuncMap{
"ToKebab": strcase.ToKebab,
}
Expand Down
2 changes: 2 additions & 0 deletions internal/template/ts_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package template

import "path/filepath"

// TSSourceFiles is a list of templates of files that will be in the "app" folder of a Poly project
// if TypeScript is used as the language of choice for the portable layer.
var TSSourceFiles = []templateFile{TSConfigJSON, PackageJSON, TSGitIgnore, TSMainFile}

var TSConfigJSON = templateFile{
Expand Down

0 comments on commit bd206c2

Please sign in to comment.