|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/qri-io/qri/repo" |
| 5 | + "github.com/spf13/cobra" |
| 6 | +) |
| 7 | + |
| 8 | +// RegistryCmd is the subcommand for working with configured registries |
| 9 | +var RegistryCmd = &cobra.Command{ |
| 10 | + Use: "registry", |
| 11 | + Short: "commands for working with a qri registry", |
| 12 | + Long: `Registries are federated public records of datasets and peers. |
| 13 | +These records form a public facing central lookup for your datasets, so others |
| 14 | +can find them through search tools and via web links. You can use registry |
| 15 | +commands to control how your datasets are published to registries, opting out |
| 16 | +on a dataset-by-dataset basis. |
| 17 | +
|
| 18 | +By default qri is configured to publish to https://registry.qri.io, |
| 19 | +the main public collection of datasets & peers. "qri add" and "qri update" |
| 20 | +default to publishing to a registry as part of dataset creation unless run |
| 21 | +with the "no-registry" flag. |
| 22 | +
|
| 23 | +Unpublished dataset info will be held locally so you can still interact |
| 24 | +with it. And your datasets will be available to others peers when you run |
| 25 | +"qri connect", but will not show up in search results, and will not be |
| 26 | +displayed on lists of registry datasets. |
| 27 | +
|
| 28 | +Qri is designed to work without a registry should you want to opt out of |
| 29 | +centralized listing entirely, but know that peers who *do* participate in |
| 30 | +registries may choose to deprioritize connections with you. Opting out of a |
| 31 | +registry entirely is better left to advanced users. |
| 32 | +
|
| 33 | +You can opt out of registries entirely by running: |
| 34 | +$ qri config set registry.location ""`, |
| 35 | + |
| 36 | + Annotations: map[string]string{ |
| 37 | + "group": "network", |
| 38 | + }, |
| 39 | +} |
| 40 | + |
| 41 | +// publishCmd represents the export command |
| 42 | +var publishCmd = &cobra.Command{ |
| 43 | + Use: "publish", |
| 44 | + Short: "publish dataset info to the registry", |
| 45 | + Example: ` Publish a dataset you've created to the registry: |
| 46 | + $ qri registry publish me/dataset_name`, |
| 47 | + PreRun: func(cmd *cobra.Command, args []string) { |
| 48 | + loadConfig() |
| 49 | + }, |
| 50 | + Args: cobra.MinimumNArgs(1), |
| 51 | + Run: func(cmd *cobra.Command, args []string) { |
| 52 | + req, err := registryRequests(false) |
| 53 | + ExitIfErr(err) |
| 54 | + |
| 55 | + var res bool |
| 56 | + for _, arg := range args { |
| 57 | + ref, err := repo.ParseDatasetRef(arg) |
| 58 | + ExitIfErr(err) |
| 59 | + |
| 60 | + err = req.Publish(&ref, &res) |
| 61 | + ExitIfErr(err) |
| 62 | + printInfo("published dataset %s", ref) |
| 63 | + } |
| 64 | + }, |
| 65 | +} |
| 66 | + |
| 67 | +// unpublishCmd represents the export command |
| 68 | +var unpublishCmd = &cobra.Command{ |
| 69 | + Use: "unpublish", |
| 70 | + Short: "remove dataset info from the registry", |
| 71 | + Example: ` Remove a dataset from the registry: |
| 72 | + $ qri registry unpublish me/dataset_name`, |
| 73 | + PreRun: func(cmd *cobra.Command, args []string) { |
| 74 | + loadConfig() |
| 75 | + }, |
| 76 | + Args: cobra.MinimumNArgs(1), |
| 77 | + Run: func(cmd *cobra.Command, args []string) { |
| 78 | + req, err := registryRequests(false) |
| 79 | + ExitIfErr(err) |
| 80 | + |
| 81 | + var res bool |
| 82 | + for _, arg := range args { |
| 83 | + ref, err := repo.ParseDatasetRef(arg) |
| 84 | + ExitIfErr(err) |
| 85 | + |
| 86 | + err = req.Unpublish(&ref, &res) |
| 87 | + ExitIfErr(err) |
| 88 | + printInfo("unpublished dataset %s", ref) |
| 89 | + } |
| 90 | + }, |
| 91 | +} |
| 92 | + |
| 93 | +func init() { |
| 94 | + RegistryCmd.AddCommand(publishCmd) |
| 95 | + RegistryCmd.AddCommand(unpublishCmd) |
| 96 | + RootCmd.AddCommand(RegistryCmd) |
| 97 | +} |
0 commit comments