diff --git a/.vscode/launch.json b/.vscode/launch.json index d644bc4..4e22e0d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,12 +5,13 @@ "version": "0.2.0", "configurations": [ { - "name": "github-config export orga", + "name": "github-config organization export", "type": "go", "request": "launch", "mode": "auto", "program": "main.go", "args": [ + "organization", "export", "-t", "${env:GITHUB_OAUTH}", @@ -28,12 +29,13 @@ } }, { - "name": "github-config export repo", + "name": "github-config repository export", "type": "go", "request": "launch", "mode": "auto", "program": "main.go", "args": [ + "repository", "export", "-t", "${env:GITHUB_OAUTH}", diff --git a/cmd/constance.go b/cmd/constance.go index 73bda4c..005e2b1 100644 --- a/cmd/constance.go +++ b/cmd/constance.go @@ -19,9 +19,16 @@ const ( flag_dry_run_description = "[default none] / Must be \"none\" or \"server\". If server strategy, only print the config informations that would be sent" // commands - cmd_export = "export" - cmd_diff = "diff" - cmd_sync = "sync" - cmd_organization = "organization" - cmd_repository = "repository" + cmd_export = "export" + cmd_diff = "diff" + cmd_sync = "sync" + + cmd_organization = "organization" + cmd_organization_desc_short = "organization command with subcommands" + cmd_organization_desc_long = `github organization command with subcommands.` + + cmd_repository = "repository" + cmd_repository_desc_short = "repository command with subcommands" + cmd_repository_desc_long = `github repository command with subcommands. + ` ) diff --git a/cmd/diff.go b/cmd/diff.go deleted file mode 100644 index 9af10ef..0000000 --- a/cmd/diff.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright © 2022 NAME HERE - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package cmd - -import ( - "golang.org/x/exp/slog" - - "github.com/spf13/cobra" -) - -// exportCmd represents the export command -var diffCmd = &cobra.Command{ - Use: cmd_diff, - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, - Run: func(cmd *cobra.Command, args []string) { - slog.Debug("command started", "cmd", cmd.CommandPath()) - cmd.Usage() - slog.Debug("command ended", "cmd", cmd.CommandPath()) - }, -} - -func init() { - rootCmd.AddCommand(diffCmd) -} diff --git a/cmd/diff_organization.go b/cmd/diff_organization.go index 7e34cce..5c62a99 100644 --- a/cmd/diff_organization.go +++ b/cmd/diff_organization.go @@ -13,7 +13,7 @@ import ( ) var diffOrganizationCmd = &cobra.Command{ - Use: cmd_organization, + Use: cmd_diff, Short: "export the github organization config", Long: `export the github organization configuration in the backup repository. @@ -71,7 +71,7 @@ var diffOrganizationCmd = &cobra.Command{ } func init() { - diffCmd.AddCommand(diffOrganizationCmd) + organizationCmd.AddCommand(diffOrganizationCmd) diffOrganizationCmd.Flags().StringVarP(&gh_personal_token, flag_gh_token, flag_gh_token_short, "", flag_gh_token_description) diffOrganizationCmd.Flags().StringVarP(&gh_organization, flag_gh_orga, flag_gh_orga_short, "", flag_gh_orga_description) diff --git a/cmd/export.go b/cmd/export.go deleted file mode 100644 index 4c4cce8..0000000 --- a/cmd/export.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright © 2022 NAME HERE - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package cmd - -import ( - "golang.org/x/exp/slog" - - "github.com/spf13/cobra" -) - -// exportCmd represents the export command -var exportCmd = &cobra.Command{ - Use: cmd_export, - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, - Run: func(cmd *cobra.Command, args []string) { - slog.Debug("command started", "cmd", cmd.CommandPath()) - cmd.Usage() - slog.Debug("command ended", "cmd", cmd.CommandPath()) - }, -} - -func init() { - rootCmd.AddCommand(exportCmd) -} diff --git a/cmd/export_organization.go b/cmd/export_organization.go index 4205f13..81f86bf 100644 --- a/cmd/export_organization.go +++ b/cmd/export_organization.go @@ -1,3 +1,18 @@ +/* +Copyright © 2022 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ package cmd import ( @@ -10,11 +25,9 @@ import ( ) var exportOrganizationCmd = &cobra.Command{ - Use: cmd_organization, - Short: "export the github organization config", - Long: `export the github organization configuration in the backup repository. - - ......`, + Use: cmd_export, + Short: "export organization ", + Long: `export organization data`, Run: func(cmd *cobra.Command, args []string) { slog.Debug("command started", "cmd", cmd.CommandPath()) @@ -102,12 +115,11 @@ var exportOrganizationCmd = &cobra.Command{ } slog.Debug("command ended", "cmd", cmd.CommandPath()) - }, } func init() { - exportCmd.AddCommand(exportOrganizationCmd) + organizationCmd.AddCommand(exportOrganizationCmd) exportOrganizationCmd.Flags().StringVarP(&gh_personal_token, flag_gh_token, flag_gh_token_short, "", flag_gh_token_description) exportOrganizationCmd.Flags().StringVarP(&gh_organization, flag_gh_orga, flag_gh_orga_short, "", flag_gh_orga_description) diff --git a/cmd/export_repository.go b/cmd/export_repository.go index 7356051..996a3f9 100644 --- a/cmd/export_repository.go +++ b/cmd/export_repository.go @@ -1,3 +1,18 @@ +/* +Copyright © 2022 NAME HERE + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ package cmd import ( @@ -9,12 +24,11 @@ import ( "github.com/spf13/cobra" ) -var repositoryCmd = &cobra.Command{ - Use: cmd_repository, - Short: "export the github repository config", - Long: `export the github repository configuration in the backup repository. - - ......`, +// exportRepositoryCmd represents the export command +var exportRepositoryCmd = &cobra.Command{ + Use: cmd_export, + Short: "export repository ", + Long: `export repository data`, Run: func(cmd *cobra.Command, args []string) { slog.Debug("command started", "cmd", cmd.CommandPath()) @@ -67,18 +81,18 @@ var repositoryCmd = &cobra.Command{ } slog.Debug("command ended", "cmd", cmd.CommandPath()) - }, } func init() { - exportCmd.AddCommand(repositoryCmd) + repositoryCmd.AddCommand(exportRepositoryCmd) + + exportRepositoryCmd.Flags().StringVarP(&gh_personal_token, flag_gh_token, flag_gh_token_short, "", flag_gh_token_description) + exportRepositoryCmd.Flags().StringVarP(&gh_organization, flag_gh_orga, flag_gh_orga_short, "", flag_gh_orga_description) + exportRepositoryCmd.Flags().StringVarP(&gh_repository, flag_gh_repo, flag_gh_repo_short, "", flag_gh_repo_description) - repositoryCmd.Flags().StringVarP(&gh_personal_token, flag_gh_token, flag_gh_token_short, "", flag_gh_token_description) - repositoryCmd.Flags().StringVarP(&gh_organization, flag_gh_orga, flag_gh_orga_short, "", flag_gh_orga_description) - repositoryCmd.Flags().StringVarP(&gh_repository, flag_gh_repo, flag_gh_repo_short, "", flag_gh_repo_description) + exportRepositoryCmd.MarkFlagRequired(flag_gh_token) + exportRepositoryCmd.MarkFlagRequired(flag_gh_orga) + exportRepositoryCmd.MarkFlagRequired(flag_gh_repo) - repositoryCmd.MarkFlagRequired(flag_gh_token) - repositoryCmd.MarkFlagRequired(flag_gh_orga) - repositoryCmd.MarkFlagRequired(flag_gh_repo) } diff --git a/cmd/organization.go b/cmd/organization.go new file mode 100644 index 0000000..1c25d5e --- /dev/null +++ b/cmd/organization.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "golang.org/x/exp/slog" + + "github.com/spf13/cobra" +) + +var organizationCmd = &cobra.Command{ + Use: cmd_organization, + Short: cmd_organization_desc_short, + Long: cmd_organization_desc_long, + Run: func(cmd *cobra.Command, args []string) { + slog.Debug("command started", "cmd", cmd.CommandPath()) + cmd.Usage() + slog.Debug("command ended", "cmd", cmd.CommandPath()) + + }, +} + +func init() { + rootCmd.AddCommand(organizationCmd) +} diff --git a/cmd/repository.go b/cmd/repository.go new file mode 100644 index 0000000..1ee2fcb --- /dev/null +++ b/cmd/repository.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "golang.org/x/exp/slog" + + "github.com/spf13/cobra" +) + +var repositoryCmd = &cobra.Command{ + Use: cmd_repository, + Short: cmd_repository_desc_short, + Long: cmd_repository_desc_long, + Run: func(cmd *cobra.Command, args []string) { + slog.Debug("command started", "cmd", cmd.CommandPath()) + cmd.Usage() + slog.Debug("command ended", "cmd", cmd.CommandPath()) + }, +} + +func init() { + rootCmd.AddCommand(repositoryCmd) +} diff --git a/cmd/sync.go b/cmd/sync.go deleted file mode 100644 index e02c656..0000000 --- a/cmd/sync.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright © 2022 NAME HERE - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package cmd - -import ( - "golang.org/x/exp/slog" - - "github.com/spf13/cobra" -) - -// exportCmd represents the export command -var syncCmd = &cobra.Command{ - Use: cmd_sync, - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, - Run: func(cmd *cobra.Command, args []string) { - slog.Debug("command started", "cmd", cmd.CommandPath()) - cmd.Usage() - slog.Debug("command ended", "cmd", cmd.CommandPath()) - }, -} - -func init() { - rootCmd.AddCommand(syncCmd) -} diff --git a/cmd/sync_organization.go b/cmd/sync_organization.go index 582d746..48bcf75 100644 --- a/cmd/sync_organization.go +++ b/cmd/sync_organization.go @@ -13,7 +13,7 @@ import ( ) var syncOrganizationCmd = &cobra.Command{ - Use: cmd_organization, + Use: cmd_sync, Short: "export the github organization config", Long: `export the github organization configuration in the backup repository. @@ -68,7 +68,7 @@ var syncOrganizationCmd = &cobra.Command{ } func init() { - syncCmd.AddCommand(syncOrganizationCmd) + organizationCmd.AddCommand(syncOrganizationCmd) syncOrganizationCmd.Flags().StringVarP(&gh_personal_token, flag_gh_token, flag_gh_token_short, "", flag_gh_token_description) syncOrganizationCmd.Flags().StringVarP(&gh_organization, flag_gh_orga, flag_gh_orga_short, "", flag_gh_orga_description)