Skip to content

Commit

Permalink
added flatpak
Browse files Browse the repository at this point in the history
initial version with missing completions
  • Loading branch information
rsteube committed Sep 16, 2023
1 parent 9e0f022 commit 15b7497
Show file tree
Hide file tree
Showing 53 changed files with 2,265 additions and 5 deletions.
92 changes: 92 additions & 0 deletions completers/flatpak_completer/cmd/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var buildCmd = &cobra.Command{
Use: "build [OPTION…] DIRECTORY [COMMAND [ARGUMENT…]]",
Short: "Build in directory",
GroupID: "build",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(buildCmd).Standalone()

buildCmd.Flags().String("add-policy", "", "Add generic policy option")
buildCmd.Flags().String("allow", "", "Allow feature")
buildCmd.Flags().String("bind-mount", "", "Add bind mount")
buildCmd.Flags().String("build-dir", "", "Start build in this directory")
buildCmd.Flags().String("device", "", "Expose device to app")
buildCmd.Flags().BoolP("die-with-parent", "p", false, "Kill processes when the parent process dies")
buildCmd.Flags().String("disallow", "", "Don't allow feature")
buildCmd.Flags().String("env", "", "Set environment variable")
buildCmd.Flags().String("env-fd", "", "Read environment variables in env -0 format from FD")
buildCmd.Flags().String("filesystem", "", "Expose filesystem to app (:ro for read-only)")
buildCmd.Flags().BoolP("help", "h", false, "Show help options")
buildCmd.Flags().Bool("help-all", false, "Show all help options")
buildCmd.Flags().Bool("log-session-bus", false, "Log session bus calls")
buildCmd.Flags().Bool("log-system-bus", false, "Log system bus calls")
buildCmd.Flags().String("metadata", "", "Use alternative file for the metadata")
buildCmd.Flags().String("no-talk-name", "", "Don't allow app to talk to name on the session bus")
buildCmd.Flags().String("nodevice", "", "Don't expose device to app")
buildCmd.Flags().String("nofilesystem", "", "Don't expose filesystem to app")
buildCmd.Flags().String("nosocket", "", "Don't expose socket to app")
buildCmd.Flags().Bool("ostree-verbose", false, "Show OSTree debug information")
buildCmd.Flags().String("own-name", "", "Allow app to own name on the session bus")
buildCmd.Flags().String("persist", "", "Persist home directory subpath")
buildCmd.Flags().Bool("readonly", false, "Make destination readonly")
buildCmd.Flags().String("remove-policy", "", "Remove generic policy option")
buildCmd.Flags().BoolP("runtime", "r", false, "Use Platform runtime rather than Sdk")
buildCmd.Flags().String("sdk-dir", "", "Where to look for custom sdk dir (defaults to 'usr')")
buildCmd.Flags().String("share", "", "Share with host")
buildCmd.Flags().String("socket", "", "Expose socket to app")
buildCmd.Flags().String("system-no-talk-name", "", "Don't allow app to talk to name on the system bus")
buildCmd.Flags().String("system-own-name", "", "Allow app to own name on the system bus")
buildCmd.Flags().String("system-talk-name", "", "Allow app to talk to name on the system bus")
buildCmd.Flags().String("talk-name", "", "Allow app to talk to name on the session bus")
buildCmd.Flags().String("unset-env", "", "Remove variable from environment")
buildCmd.Flags().String("unshare", "", "Unshare with host")
buildCmd.Flags().BoolP("verbose", "v", false, "Show debug information, -vv for more detail")
buildCmd.Flags().Bool("with-appdir", false, "Export application homedir directory to build")
rootCmd.AddCommand(buildCmd)

// TODO flag
carapace.Gen(buildCmd).FlagCompletion(carapace.ActionMap{
// "add-policy": carapace.ActionValues(),
// "allow": carapace.ActionValues(),
// "bind-mount": carapace.ActionValues(),
"build-dir": carapace.ActionDirectories(),
// "device": carapace.ActionValues(),
// "disallow": carapace.ActionValues(),
// "env": carapace.ActionValues(),
// "env-fd": carapace.ActionValues(),
// "filesystem": carapace.ActionValues(),
// "metadata": carapace.ActionValues(),
// "no-talk-name": carapace.ActionValues(),
// "nodevice": carapace.ActionValues(),
// "nofilesystem": carapace.ActionValues(),
// "nosocket": carapace.ActionValues(),
// "own-name": carapace.ActionValues(),
// "persist": carapace.ActionValues(),
// "remove-policy": carapace.ActionValues(),
"sdk-dir": carapace.ActionDirectories(),
// "share": carapace.ActionValues(),
// "socket": carapace.ActionValues(),
// "system-no-talk-name": carapace.ActionValues(),
// "system-own-name": carapace.ActionValues(),
// "system-talk-name": carapace.ActionValues(),
// "talk-name": carapace.ActionValues(),
// "unset-env": carapace.ActionValues(),
// "unshare": carapace.ActionValues(),
})

carapace.Gen(buildCmd).PositionalCompletion(
carapace.ActionDirectories(),
// TODO command
)

// TODO command arguments
}
59 changes: 59 additions & 0 deletions completers/flatpak_completer/cmd/buildCommitFrom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/spf13/cobra"
)

var buildCommitFromCmd = &cobra.Command{
Use: "build-commit-from [OPTION…] DST-REPO [DST-REF…]",
Short: "Make a new commit from existing commits",
GroupID: "build",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(buildCommitFromCmd).Standalone()

buildCommitFromCmd.Flags().StringP("body", "b", "", "Full description")
buildCommitFromCmd.Flags().Bool("disable-fsync", false, "Do not invoke fsync()")
buildCommitFromCmd.Flags().String("end-of-life", "", "Mark build as end-of-life")
buildCommitFromCmd.Flags().String("end-of-life-rebase", "", "Mark refs matching the OLDID prefix as end-of-life, to be replaced with the given NEWID")
buildCommitFromCmd.Flags().String("extra-collection-id", "", "Add an extra collection id ref and binding")
buildCommitFromCmd.Flags().Bool("force", false, "Always commit, even if same content")
buildCommitFromCmd.Flags().String("gpg-homedir", "", "GPG Homedir to use when looking for keyrings")
buildCommitFromCmd.Flags().String("gpg-sign", "", "GPG Key ID to sign the commit with")
buildCommitFromCmd.Flags().BoolP("help", "h", false, "Show help options")
buildCommitFromCmd.Flags().Bool("no-summary-index", false, "Don't generate a summary index")
buildCommitFromCmd.Flags().Bool("no-update-summary", false, "Don't update the summary")
buildCommitFromCmd.Flags().Bool("ostree-verbose", false, "Show OSTree debug information")
buildCommitFromCmd.Flags().String("src-ref", "", "Source repo ref")
buildCommitFromCmd.Flags().String("src-repo", "", "Source repo dir")
buildCommitFromCmd.Flags().StringP("subject", "s", "", "One line subject")
buildCommitFromCmd.Flags().String("subset", "", "Add to a named subset")
buildCommitFromCmd.Flags().String("timestamp", "", "Override the timestamp of the commit (NOW for current time)")
buildCommitFromCmd.Flags().String("token-type", "", "Set type of token needed to install this commit")
buildCommitFromCmd.Flags().Bool("untrusted", false, "Do not trust SRC-REPO")
buildCommitFromCmd.Flags().Bool("update-appstream", false, "Update the appstream branch")
buildCommitFromCmd.Flags().BoolP("verbose", "v", false, "Show debug information, -vv for more detail")
rootCmd.AddCommand(buildCommitFromCmd)

// TODO flag
carapace.Gen(buildCommitFromCmd).FlagCompletion(carapace.ActionMap{
// "body": carapace.ActionValues(),
// "end-of-life": carapace.ActionValues(),
// "end-of-life-rebase": carapace.ActionValues(),
// "extra-collection-id": carapace.ActionValues(),
"gpg-homedir": carapace.ActionDirectories(),
"gpg-sign": os.ActionGpgKeyIds(), // TODO handle gpg-homedir
// "src-ref": carapace.ActionValues(),
// "src-repo": carapace.ActionValues(),
// "subject": carapace.ActionValues(),
// "subset": carapace.ActionValues(),
// "timestamp": carapace.ActionValues(),
// "token-type" : carapace.ActionValues(),
})

// TODO positional
}
68 changes: 68 additions & 0 deletions completers/flatpak_completer/cmd/buildExport.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var buildExportCmd = &cobra.Command{
Use: "build-export [OPTION…] LOCATION DIRECTORY [BRANCH]",
Short: "Create a repository from a build directory",
GroupID: "build",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(buildExportCmd).Standalone()

buildExportCmd.Flags().String("arch", "", "Architecture to export for (must be host compatible)")
buildExportCmd.Flags().StringP("body", "b", "", "Full description")
buildExportCmd.Flags().String("collection-id", "", "Collection ID")
buildExportCmd.Flags().Bool("disable-fsync", false, "Do not invoke fsync()")
buildExportCmd.Flags().Bool("disable-sandbox", false, "Do not sandbox icon validator")
buildExportCmd.Flags().String("end-of-life", "", "Mark build as end-of-life")
buildExportCmd.Flags().String("end-of-life-rebase", "", "Mark build as end-of-life, to be replaced with the given ID")
buildExportCmd.Flags().String("exclude", "", "Files to exclude")
buildExportCmd.Flags().String("files", "", "Use alternative directory for the files")
buildExportCmd.Flags().String("gpg-homedir", "", "GPG Homedir to use when looking for keyrings")
buildExportCmd.Flags().String("gpg-sign", "", "GPG Key ID to sign the commit with")
buildExportCmd.Flags().BoolP("help", "h", false, "Show help options")
buildExportCmd.Flags().String("include", "", "Excluded files to include")
buildExportCmd.Flags().String("metadata", "", "Use alternative file for the metadata")
buildExportCmd.Flags().Bool("no-summary-index", false, "Don't generate a summary index")
buildExportCmd.Flags().Bool("no-update-summary", false, "Don't update the summary")
buildExportCmd.Flags().Bool("ostree-verbose", false, "Show OSTree debug information")
buildExportCmd.Flags().BoolP("runtime", "r", false, "Commit runtime (/usr), not /app")
buildExportCmd.Flags().StringP("subject", "s", "", "One line subject")
buildExportCmd.Flags().String("subset", "", "Add to a named subset")
buildExportCmd.Flags().String("timestamp", "", "Override the timestamp of the commit")
buildExportCmd.Flags().String("token-type", "", "Set type of token needed to install this commit")
buildExportCmd.Flags().Bool("update-appstream", false, "Update the appstream branch")
buildExportCmd.Flags().BoolP("verbose", "v", false, "Show debug information, -vv for more detail")
rootCmd.AddCommand(buildExportCmd)

// TODO flag
carapace.Gen(buildExportCmd).FlagCompletion(carapace.ActionMap{
// "arch": carapace.ActionValues(),
// "body": carapace.ActionValues(),
// "collection-id": carapace.ActionValues(),
// "end-of-life": carapace.ActionValues(),
// "end-of-life-rebase": carapace.ActionValues(),
// "exclude": carapace.ActionValues(),
// "files": carapace.ActionValues(),
// "gpg-homedir": carapace.ActionValues(),
// "gpg-sign": carapace.ActionValues(),
// "include": carapace.ActionValues(),
// "metadata": carapace.ActionValues(),
// "subject": carapace.ActionValues(),
// "subset": carapace.ActionValues(),
// "timestamp": carapace.ActionValues(),
// "token-type": carapace.ActionValues(),
})

carapace.Gen(buildExportCmd).PositionalCompletion(
carapace.ActionValues(), // TODO location
carapace.ActionDirectories(),
carapace.ActionValues(), // TODO branch
)
}
94 changes: 94 additions & 0 deletions completers/flatpak_completer/cmd/buildFinish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var buildFinishCmd = &cobra.Command{
Use: "build-finish [OPTION…] DIRECTORY",
Short: "Finalize a build directory",
GroupID: "build",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(buildFinishCmd).Standalone()

buildFinishCmd.Flags().String("add-policy", "", "Add generic policy option")
buildFinishCmd.Flags().String("allow", "", "Allow feature")
buildFinishCmd.Flags().String("command", "", "Command to set")
buildFinishCmd.Flags().String("device", "", "Expose device to app")
buildFinishCmd.Flags().String("disallow", "", "Don't allow feature")
buildFinishCmd.Flags().String("env", "", "Set environment variable")
buildFinishCmd.Flags().String("env-fd", "", "Read environment variables in env -0 format from FD")
buildFinishCmd.Flags().String("extension", "", "Add extension point info")
buildFinishCmd.Flags().String("extension-priority", "", "Set extension priority (only for extensions)")
buildFinishCmd.Flags().Bool("extra-data", false, "Extra data info")
buildFinishCmd.Flags().String("filesystem", "", "Expose filesystem to app (:ro for read-only)")
buildFinishCmd.Flags().BoolP("help", "h", false, "Show help options")
buildFinishCmd.Flags().Bool("help-all", false, "Show all help options")
buildFinishCmd.Flags().String("metadata", "", "Set generic metadata option")
buildFinishCmd.Flags().Bool("no-exports", false, "Don't process exports")
buildFinishCmd.Flags().Bool("no-inherit-permissions", false, "Don't inherit permissions from runtime")
buildFinishCmd.Flags().String("no-talk-name", "", "Don't allow app to talk to name on the session bus")
buildFinishCmd.Flags().String("nodevice", "", "Don't expose device to app")
buildFinishCmd.Flags().String("nofilesystem", "", "Don't expose filesystem to app")
buildFinishCmd.Flags().String("nosocket", "", "Don't expose socket to app")
buildFinishCmd.Flags().Bool("ostree-verbose", false, "Show OSTree debug information")
buildFinishCmd.Flags().String("own-name", "", "Allow app to own name on the session bus")
buildFinishCmd.Flags().String("persist", "", "Persist home directory subpath")
buildFinishCmd.Flags().String("remove-extension", "", "Remove extension point info")
buildFinishCmd.Flags().String("remove-policy", "", "Remove generic policy option")
buildFinishCmd.Flags().String("require-version", "", "Flatpak version to require")
buildFinishCmd.Flags().String("runtime", "", "Change the runtime used for the app")
buildFinishCmd.Flags().String("sdk", "", "Change the sdk used for the app")
buildFinishCmd.Flags().String("share", "", "Share with host")
buildFinishCmd.Flags().String("socket", "", "Expose socket to app")
buildFinishCmd.Flags().String("system-no-talk-name", "", "Don't allow app to talk to name on the system bus")
buildFinishCmd.Flags().String("system-own-name", "", "Allow app to own name on the system bus")
buildFinishCmd.Flags().String("system-talk-name", "", "Allow app to talk to name on the system bus")
buildFinishCmd.Flags().String("talk-name", "", "Allow app to talk to name on the session bus")
buildFinishCmd.Flags().String("unset-env", "", "Remove variable from environment")
buildFinishCmd.Flags().String("unshare", "", "Unshare with host")
buildFinishCmd.Flags().BoolP("verbose", "v", false, "Show debug information, -vv for more detail")
rootCmd.AddCommand(buildFinishCmd)

// TODO flags
carapace.Gen(buildFinishCmd).FlagCompletion(carapace.ActionMap{
// "add-policy": carapace.ActionValues().
// "allow": carapace.ActionValues().
// "command": carapace.ActionValues().
// "device": carapace.ActionValues().
// "disallow": carapace.ActionValues().
// "env": carapace.ActionValues().
// "env-fd": carapace.ActionValues().
// "extension": carapace.ActionValues().
// "extension-priority": carapace.ActionValues().
// "filesystem": carapace.ActionValues().
// "metadata": carapace.ActionValues().
// "no-talk-name": carapace.ActionValues().
// "nodevice": carapace.ActionValues().
// "nofilesystem": carapace.ActionValues().
// "nosocket": carapace.ActionValues().
// "own-name": carapace.ActionValues().
// "persist": carapace.ActionValues().
// "remove-extension": carapace.ActionValues().
// "remove-policy": carapace.ActionValues().
// "require-version": carapace.ActionValues().
// "runtime": carapace.ActionValues().
// "sdk": carapace.ActionValues().
// "share": carapace.ActionValues().
// "socket": carapace.ActionValues().
// "system-no-talk-name": carapace.ActionValues().
// "system-own-name": carapace.ActionValues().
// "system-talk-name": carapace.ActionValues().
// "talk-name": carapace.ActionValues().
// "unset-env": carapace.ActionValues().
// "unshare" : carapace.ActionValues().
})

carapace.Gen(buildFinishCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
41 changes: 41 additions & 0 deletions completers/flatpak_completer/cmd/buildImportBundle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/spf13/cobra"
)

var buildImportBundleCmd = &cobra.Command{
Use: "build-import-bundle [OPTION…] LOCATION FILENAME",
Short: "Import a file bundle into a local repository",
GroupID: "build",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(buildImportBundleCmd).Standalone()

buildImportBundleCmd.Flags().String("gpg-homedir", "", "GPG Homedir to use when looking for keyrings")
buildImportBundleCmd.Flags().String("gpg-sign", "", "GPG Key ID to sign the commit with")
buildImportBundleCmd.Flags().BoolP("help", "h", false, "Show help options")
buildImportBundleCmd.Flags().Bool("no-summary-index", false, "Don't generate a summary index")
buildImportBundleCmd.Flags().Bool("no-update-summary", false, "Don't update the summary")
buildImportBundleCmd.Flags().Bool("oci", false, "Import oci image instead of flatpak bundle")
buildImportBundleCmd.Flags().Bool("ostree-verbose", false, "Show OSTree debug information")
buildImportBundleCmd.Flags().String("ref", "", "Override the ref used for the imported bundle")
buildImportBundleCmd.Flags().Bool("update-appstream", false, "Update the appstream branch")
buildImportBundleCmd.Flags().BoolP("verbose", "v", false, "Show debug information, -vv for more detail")
rootCmd.AddCommand(buildImportBundleCmd)

carapace.Gen(buildImportBundleCmd).FlagCompletion(carapace.ActionMap{
"gpg-homedir": carapace.ActionDirectories(),
"gpg-sign": os.ActionGpgKeyIds(), // TODO handle gpg-homedir flag
// "ref": carapace.ActionValues(), // TODO
})

carapace.Gen(buildImportBundleCmd).PositionalCompletion(
carapace.ActionValues(), // TODO location
carapace.ActionFiles(),
)
}
Loading

0 comments on commit 15b7497

Please sign in to comment.