Commits

Tjerk Santegoeds  committed 5dfd08c

Fix default command when no arguments are provided

  • Participants
  • Parent commits 9754f95

Comments (0)

Files changed (2)

 
         scriptname = argv[0]
 
+        if len(argv) < 2 and self.defaultcommand:
+            argv.append(self.defaultcommand.name)
+
         if (len(argv) < 2) or (argv[1] == "-h" or argv[1] == "--help"):
             # Print the documentation for the script
             raise TopHelp(scriptname)

File tests/main.py

         def test(a, b, c):
             return (a, b, c)
         self.assertEqual(b.run(["s", "test", "1", "2", "3"], main=False), ("1", "2", "3"))
-        
+
     def test_default(self):
         b = baker.Baker()
         @b.command(default=True)
-        def test(a, b, c):
+        def test(a="a", b="b", c="b"):
             return (a, b, c)
         self.assertEqual(b.run(["s", "1", "2", "3"], main=False), ("1", "2", "3"))
-    
+        self.assertEqual(b.run(["s"], main=False), ("a", "b", "c"))
+
     def test_options(self):
         b = baker.Baker()
         @b.command