Skip to content

Commit

Permalink
Reorganize the cmd package (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
telegrapher authored Apr 26, 2024
1 parent ac780e7 commit 62170de
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 45 deletions.
5 changes: 3 additions & 2 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package cmd

import (
"github.com/adobe/imscli/cmd/admin"
"github.com/adobe/imscli/ims"
"github.com/spf13/cobra"
)
Expand All @@ -26,8 +27,8 @@ This command has no effect by itself, the request needs to be specified as a sub
`,
}
cmd.AddCommand(
adminProfileCmd(imsConfig),
adminOrganizationsCmd(imsConfig),
admin.ProfileCmd(imsConfig),
admin.OrganizationsCmd(imsConfig),
)
return cmd
}
4 changes: 2 additions & 2 deletions cmd/admin_organizations.go → cmd/admin/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package admin

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func adminOrganizationsCmd(imsConfig *ims.Config) *cobra.Command {
func OrganizationsCmd(imsConfig *ims.Config) *cobra.Command {

cmd := &cobra.Command{
Use: "organizations",
Expand Down
4 changes: 2 additions & 2 deletions cmd/admin_profile.go → cmd/admin/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package admin

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func adminProfileCmd(imsConfig *ims.Config) *cobra.Command {
func ProfileCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "profile",
Short: "Requests the user profile using the admin API.",
Expand Down
11 changes: 6 additions & 5 deletions cmd/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package cmd

import (
"github.com/adobe/imscli/cmd/authz"
"github.com/adobe/imscli/ims"
"github.com/spf13/cobra"
)
Expand All @@ -26,11 +27,11 @@ This command has no effect by itself, the authorization type needs to be specifi
`,
}
cmd.AddCommand(
authzUserCmd(imsConfig),
authzUserPkceCmd(imsConfig),
authzServiceCmd(imsConfig),
authzJWTCmd(imsConfig),
authzClientCredentialsCmd(imsConfig),
authz.UserCmd(imsConfig),
authz.UserPkceCmd(imsConfig),
authz.ServiceCmd(imsConfig),
authz.JWTCmd(imsConfig),
authz.ClientCredentialsCmd(imsConfig),
)
return cmd
}
4 changes: 2 additions & 2 deletions cmd/authz_client.go → cmd/authz/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package authz

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func authzClientCredentialsCmd(imsConfig *ims.Config) *cobra.Command {
func ClientCredentialsCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "clientCredentials",
Aliases: []string{"client"},
Expand Down
4 changes: 2 additions & 2 deletions cmd/authz_jwt.go → cmd/authz/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package authz

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func authzJWTCmd(imsConfig *ims.Config) *cobra.Command {
func JWTCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "jwt",
Short: "Exchange a JWT for an access token.",
Expand Down
4 changes: 2 additions & 2 deletions cmd/authz_pkce.go → cmd/authz/pkce.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package authz

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func authzUserPkceCmd(imsConfig *ims.Config) *cobra.Command {
func UserPkceCmd(imsConfig *ims.Config) *cobra.Command {

cmd := &cobra.Command{
Use: "pkce",
Expand Down
4 changes: 2 additions & 2 deletions cmd/authz_service.go → cmd/authz/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package authz

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func authzServiceCmd(imsConfig *ims.Config) *cobra.Command {
func ServiceCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "service",
Short: "Negotiate a service to service token.",
Expand Down
4 changes: 2 additions & 2 deletions cmd/authz_user.go → cmd/authz/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package authz

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func authzUserCmd(imsConfig *ims.Config) *cobra.Command {
func UserCmd(imsConfig *ims.Config) *cobra.Command {

cmd := &cobra.Command{
Use: "user",
Expand Down
9 changes: 5 additions & 4 deletions cmd/invalidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package cmd

import (
"github.com/adobe/imscli/cmd/invalidate"
"github.com/adobe/imscli/ims"
"github.com/spf13/cobra"
)
Expand All @@ -27,10 +28,10 @@ This command has no effect by itself, the token type must be specified as a subc
`,
}
cmd.AddCommand(
invalidateAccessTokenCmd(imsConfig),
invalidateRefreshTokenCmd(imsConfig),
invalidateDeviceTokenCmd(imsConfig),
invalidateServiceTokenCmd(imsConfig),
invalidate.AccessTokenCmd(imsConfig),
invalidate.RefreshTokenCmd(imsConfig),
invalidate.DeviceTokenCmd(imsConfig),
invalidate.ServiceTokenCmd(imsConfig),
)
return cmd
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package invalidate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func invalidateAccessTokenCmd(imsConfig *ims.Config) *cobra.Command {
func AccessTokenCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "accessToken",
Aliases: []string{"acc"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package invalidate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func invalidateDeviceTokenCmd(imsConfig *ims.Config) *cobra.Command {
func DeviceTokenCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "deviceToken",
Aliases: []string{"dev"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package invalidate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func invalidateRefreshTokenCmd(imsConfig *ims.Config) *cobra.Command {
func RefreshTokenCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "refreshToken",
Aliases: []string{"ref"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package invalidate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func invalidateServiceTokenCmd(imsConfig *ims.Config) *cobra.Command {
func ServiceTokenCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "serviceToken",
Aliases: []string{"svc"},
Expand Down
9 changes: 5 additions & 4 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package cmd

import (
"github.com/adobe/imscli/cmd/validate"
"github.com/adobe/imscli/ims"
"github.com/spf13/cobra"
)
Expand All @@ -27,10 +28,10 @@ This command has no effect by itself, the token type must be specified as a subc
`,
}
cmd.AddCommand(
validateAccessTokenCmd(imsConfig),
validateRefreshTokenCmd(imsConfig),
validateDeviceTokenCmd(imsConfig),
validateAuthzCodeCmd(imsConfig),
validate.AccessTokenCmd(imsConfig),
validate.RefreshTokenCmd(imsConfig),
validate.DeviceTokenCmd(imsConfig),
validate.AuthzCodeCmd(imsConfig),
)
return cmd
}
4 changes: 2 additions & 2 deletions cmd/validate_access_token.go → cmd/validate/access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package validate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func validateAccessTokenCmd(imsConfig *ims.Config) *cobra.Command {
func AccessTokenCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "accessToken",
Aliases: []string{"acc"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package validate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func validateAuthzCodeCmd(imsConfig *ims.Config) *cobra.Command {
func AuthzCodeCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "authorizationCode",
Aliases: []string{"authz"},
Expand Down
4 changes: 2 additions & 2 deletions cmd/validate_device_token.go → cmd/validate/device_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package validate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func validateDeviceTokenCmd(imsConfig *ims.Config) *cobra.Command {
func DeviceTokenCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "deviceToken",
Aliases: []string{"dev"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.

package cmd
package validate

import (
"fmt"
Expand All @@ -17,7 +17,7 @@ import (
"github.com/spf13/cobra"
)

func validateRefreshTokenCmd(imsConfig *ims.Config) *cobra.Command {
func RefreshTokenCmd(imsConfig *ims.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "refreshToken",
Aliases: []string{"ref"},
Expand Down

0 comments on commit 62170de

Please sign in to comment.