Skip to content

Commit

Permalink
Merge pull request #3383 from apostasie/refactor-cmd-2
Browse files Browse the repository at this point in the history
Refactor cmd/nerdctl, part 2
  • Loading branch information
AkihiroSuda authored Sep 3, 2024
2 parents f2bfc60 + 4e89ddf commit 863457d
Show file tree
Hide file tree
Showing 145 changed files with 661 additions and 532 deletions.
8 changes: 4 additions & 4 deletions cmd/nerdctl/compose.go → cmd/nerdctl/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand All @@ -23,7 +23,7 @@ import (
"github.com/containerd/nerdctl/v2/pkg/composer"
)

func newComposeCommand() *cobra.Command {
func NewComposeCommand() *cobra.Command {
var composeCommand = &cobra.Command{
Use: "compose [flags] COMMAND",
Short: "Compose",
Expand All @@ -33,7 +33,7 @@ func newComposeCommand() *cobra.Command {
TraverseChildren: true, // required for global short hands like -f
}
// `-f` is a nonPersistentAlias, as it conflicts with `nerdctl compose logs --follow`
AddPersistentStringArrayFlag(composeCommand, "file", nil, []string{"f"}, nil, "", "Specify an alternate compose file")
helpers.AddPersistentStringArrayFlag(composeCommand, "file", nil, []string{"f"}, nil, "", "Specify an alternate compose file")
composeCommand.PersistentFlags().String("project-directory", "", "Specify an alternate working directory")
composeCommand.PersistentFlags().StringP("project-name", "p", "", "Specify an alternate project name")
composeCommand.PersistentFlags().String("env-file", "", "Specify an alternate environment file")
Expand Down Expand Up @@ -70,7 +70,7 @@ func newComposeCommand() *cobra.Command {
}

func getComposeOptions(cmd *cobra.Command, debugFull, experimental bool) (composer.Options, error) {
nerdctlCmd, nerdctlArgs := globalFlags(cmd)
nerdctlCmd, nerdctlArgs := helpers.GlobalFlags(cmd)
projectDirectory, err := cmd.Flags().GetString("project-directory")
if err != nil {
return composer.Options{}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"github.com/spf13/cobra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
27 changes: 27 additions & 0 deletions cmd/nerdctl/compose/compose_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright The containerd Authors.
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 compose

import (
"testing"

"github.com/containerd/nerdctl/v2/pkg/testutil"
)

func TestMain(m *testing.M) {
testutil.M(m)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package compose

import (
"fmt"
Expand Down
Loading

0 comments on commit 863457d

Please sign in to comment.