URI: 
       commands: Make the limit command work again - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 73825cfc1c0b007830b24bb1947a565175b52d36
   DIR parent a8f7fbbb10aa78f3ebac008d29d9969bb197393c
  HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Wed, 11 Apr 2018 08:31:18 +0200
       
       commands: Make the limit command work again
       
       See #4598
       
       Diffstat:
         M commands/check.go                   |       4 +++-
         A commands/check_darwin.go            |      36 +++++++++++++++++++++++++++++++
         M commands/commands_test.go           |      55 +++++++++++++++++++-------------
         M commands/limit_others.go            |      14 +-------------
       
       4 files changed, 73 insertions(+), 36 deletions(-)
       ---
   DIR diff --git a/commands/check.go b/commands/check.go
       @@ -1,4 +1,4 @@
       -// Copyright 2015 The Hugo Authors. All rights reserved.
       +// Copyright 2018 The Hugo Authors. All rights reserved.
        //
        // Licensed under the Apache License, Version 2.0 (the "License");
        // you may not use this file except in compliance with the License.
       @@ -11,6 +11,8 @@
        // See the License for the specific language governing permissions and
        // limitations under the License.
        
       +// +build !darwin
       +
        package commands
        
        import (
   DIR diff --git a/commands/check_darwin.go b/commands/check_darwin.go
       @@ -0,0 +1,36 @@
       +// Copyright 2018 The Hugo Authors. All rights reserved.
       +//
       +// 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 commands
       +
       +import (
       +        "github.com/spf13/cobra"
       +)
       +
       +var _ cmder = (*checkCmd)(nil)
       +
       +type checkCmd struct {
       +        *baseCmd
       +}
       +
       +func newCheckCmd() *checkCmd {
       +        cc := &checkCmd{baseCmd: &baseCmd{cmd: &cobra.Command{
       +                Use:   "check",
       +                Short: "Contains some verification checks",
       +        },
       +        }}
       +
       +        cc.cmd.AddCommand(newLimitCmd().getCommand())
       +
       +        return cc
       +}
   DIR diff --git a/commands/commands_test.go b/commands/commands_test.go
       @@ -41,31 +41,33 @@ func TestCommands(t *testing.T) {
                sourceFlag := fmt.Sprintf("-s=%s", dir)
        
                tests := []struct {
       -                commands []string
       -                flags    []string
       +                commands           []string
       +                flags              []string
       +                expectErrToContain string
                }{
       -                {[]string{"check", "ulimit"}, nil},
       -                {[]string{"env"}, nil},
       -                {[]string{"version"}, nil},
       +                // TODO(bep) permission issue on my OSX? "operation not permitted" {[]string{"check", "ulimit"}, nil, false},
       +                {[]string{"env"}, nil, ""},
       +                {[]string{"version"}, nil, ""},
                        // no args = hugo build
       -                {nil, []string{sourceFlag}},
       +                {nil, []string{sourceFlag}, ""},
                        // TODO(bep) cli refactor remove the HugoSites global and enable the below
       -                //{nil, []string{sourceFlag, "--renderToMemory"}},
       -                {[]string{"benchmark"}, []string{sourceFlag, "-n=1"}},
       -                {[]string{"convert", "toTOML"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "toml")}},
       -                {[]string{"convert", "toYAML"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "yaml")}},
       -                {[]string{"convert", "toJSON"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "json")}},
       -                {[]string{"gen", "autocomplete"}, []string{"--completionfile=" + filepath.Join(dirOut, "autocomplete.txt")}},
       -                {[]string{"gen", "chromastyles"}, []string{"--style=manni"}},
       -                {[]string{"gen", "doc"}, []string{"--dir=" + filepath.Join(dirOut, "doc")}},
       -                {[]string{"gen", "man"}, []string{"--dir=" + filepath.Join(dirOut, "man")}},
       -                {[]string{"list", "drafts"}, []string{sourceFlag}},
       -                {[]string{"list", "expired"}, []string{sourceFlag}},
       -                {[]string{"list", "future"}, []string{sourceFlag}},
       -                {[]string{"new", "new-page.md"}, []string{sourceFlag}},
       -                {[]string{"new", "site", filepath.Join(dirOut, "new-site")}, nil},
       +                //{nil, []string{sourceFlag, "--renderToMemory"},false},
       +                {[]string{"benchmark"}, []string{sourceFlag, "-n=1"}, ""},
       +                {[]string{"convert", "toTOML"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "toml")}, ""},
       +                {[]string{"convert", "toYAML"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "yaml")}, ""},
       +                {[]string{"convert", "toJSON"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "json")}, ""},
       +                {[]string{"gen", "autocomplete"}, []string{"--completionfile=" + filepath.Join(dirOut, "autocomplete.txt")}, ""},
       +                {[]string{"gen", "chromastyles"}, []string{"--style=manni"}, ""},
       +                {[]string{"gen", "doc"}, []string{"--dir=" + filepath.Join(dirOut, "doc")}, ""},
       +                {[]string{"gen", "man"}, []string{"--dir=" + filepath.Join(dirOut, "man")}, ""},
       +                {[]string{"list", "drafts"}, []string{sourceFlag}, ""},
       +                {[]string{"list", "expired"}, []string{sourceFlag}, ""},
       +                {[]string{"list", "future"}, []string{sourceFlag}, ""},
       +                {[]string{"new", "new-page.md"}, []string{sourceFlag}, ""},
       +                {[]string{"new", "site", filepath.Join(dirOut, "new-site")}, nil, ""},
       +                {[]string{"unknowncommand"}, nil, "unknown command"},
                        // TODO(bep) cli refactor fix https://github.com/gohugoio/hugo/issues/4450
       -                //{[]string{"new", "theme", filepath.Join(dirOut, "new-theme")}, nil},
       +                //{[]string{"new", "theme", filepath.Join(dirOut, "new-theme")}, nil,false},
                }
        
                for _, test := range tests {
       @@ -75,8 +77,17 @@ func TestCommands(t *testing.T) {
                        hugoCmd.SetArgs(append(test.commands, test.flags...))
        
                        // TODO(bep) capture output and add some simple asserts
       +                // TODO(bep) misspelled subcommands does not return an error. We should investigate this
       +                // but before that, check for "Error: unknown command".
       +
       +                _, err := hugoCmd.ExecuteC()
       +                if test.expectErrToContain != "" {
       +                        assert.Error(err, fmt.Sprintf("%v", test.commands))
       +                        assert.Contains(err.Error(), test.expectErrToContain)
       +                } else {
       +                        assert.NoError(err, fmt.Sprintf("%v", test.commands))
       +                }
        
       -                assert.NoError(hugoCmd.Execute(), fmt.Sprintf("%v", test.commands))
                }
        
        }
   DIR diff --git a/commands/limit_others.go b/commands/limit_others.go
       @@ -1,4 +1,4 @@
       -// Copyright 2015 The Hugo Authors. All rights reserved.
       +// Copyright 2018 The Hugo Authors. All rights reserved.
        //
        // Licensed under the Apache License, Version 2.0 (the "License");
        // you may not use this file except in compliance with the License.
       @@ -12,18 +12,6 @@
        // limitations under the License.
        
        // +build !darwin
       -// Copyright 2015 The Hugo Authors. All rights reserved.
       -//
       -// 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 commands