From bd67fa329cc27fb241edae3a06c024451dbabe8e Mon Sep 17 00:00:00 2001 From: Matthew Rose Date: Sat, 9 Oct 2021 15:01:00 +1000 Subject: [PATCH] feat: add initial composite action struct representation --- cmd/root.go | 15 +-------------- pkg/types/composite_action.go | 31 +++++++++++++++++++++++++++++++ pkg/types/input.go | 30 ++++++++++++++++++++++++++++++ pkg/types/output.go | 29 +++++++++++++++++++++++++++++ pkg/types/third_party_action.go | 29 +++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 pkg/types/composite_action.go create mode 100644 pkg/types/input.go create mode 100644 pkg/types/output.go create mode 100644 pkg/types/third_party_action.go diff --git a/cmd/root.go b/cmd/root.go index 40c2f28..a35a79d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -34,16 +34,7 @@ var cfgFile string // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "gha-docs", - Short: "A brief description of your application", - Long: `A longer description that spans multiple lines and likely contains -examples and usage of using your application. 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.`, - // Uncomment the following line if your bare application - // has an action associated with it: - // Run: func(cmd *cobra.Command, args []string) { }, + Short: "A program to generate documentation for composite GitHub actions.", } // Execute adds all child commands to the root command and sets flags appropriately. @@ -60,10 +51,6 @@ func init() { // will be global for your application. rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gha-docs.yaml)") - - // Cobra also supports local flags, which will only run - // when this action is called directly. - rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } // initConfig reads in config file and ENV variables if set. diff --git a/pkg/types/composite_action.go b/pkg/types/composite_action.go new file mode 100644 index 0000000..3914ef3 --- /dev/null +++ b/pkg/types/composite_action.go @@ -0,0 +1,31 @@ +/* +Copyright © 2021 Matt Rose + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package action + +// CompositeAction represents a single composite action. +type CompositeAction struct { + Name string + Description string + Inputs []Input + Outputs []Output + ThirdPartyActions []ThirdPartyAction +} diff --git a/pkg/types/input.go b/pkg/types/input.go new file mode 100644 index 0000000..7f68068 --- /dev/null +++ b/pkg/types/input.go @@ -0,0 +1,30 @@ +/* +Copyright © 2021 Matt Rose + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package action + +// Input represents a single input to a composite action. +type Input struct { + Name string + Description string + Required bool + Default string +} diff --git a/pkg/types/output.go b/pkg/types/output.go new file mode 100644 index 0000000..fc52699 --- /dev/null +++ b/pkg/types/output.go @@ -0,0 +1,29 @@ +/* +Copyright © 2021 Matt Rose + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package action + +// Output represents a single output of a composite action. +type Output struct { + Name string + Description string + Value string +} diff --git a/pkg/types/third_party_action.go b/pkg/types/third_party_action.go new file mode 100644 index 0000000..139c3f4 --- /dev/null +++ b/pkg/types/third_party_action.go @@ -0,0 +1,29 @@ +/* +Copyright © 2021 Matt Rose + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package action + +// ThirdPartyAction represents a single third party action that is used within the composite action. +type ThirdPartyAction struct { + Creator string + Name string + Version string +}