Ali Afshar avatar Ali Afshar committed 73f020d

Use an actual sanescript command

Comments (0)

Files changed (6)

+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+kij script
+~~~~~~~~~~
+"""
+
+from kij.commands import kij_script
+
+
+if __name__ == '__main__':
+    kij_script.main()
+
+
 name: kij
-summary: experiment about replacing distutils, setuptools, virtualenv and pip
-version: !sh hg parents --template '{latesttag}.dev{latesttagdistance}\n'
+
+summary: Python packaging and distribution utilities
+
 packages:
-- kij.*
+    - kij.*
 
+scripts:
+    - bin/kij
+
+

kij/commands/__init__.py

+
+"""
+    kij.commands
+    ~~~~~~~~~~~~
+
+    Command line interface to kij
+"""
+
+
+import os
+
+import py
+
+from sanescript import Script, Command, Option
+
+from build import BuildCommand
+
+
+class KijScript(Script):
+
+    options = [
+        Option(
+            'source_directory',
+            help='The source code directory',
+            default=py.path.local(os.getcwd()),
+            processor=py.path.local
+        ),
+    ]
+
+
+class KijCommand(Command):
+    """The base Kij command
+    """
+
+kij_script = KijScript()
+kij_script.add_command(BuildCommand)
+

kij/commands/build.py

 
 import sys
 
+from sanescript import Command, Option
+
+from kij.task_queue import Queue
 from kij.tasks.build import Build
 
 
                    build_lib=build_lib,
                    build_scripts=build_scripts,
                    ))
+
+
+class BuildCommand(Command):
+
+    name = 'build'
+
+    def __call__(self, config):
+        queue = Queue()
+        build = config.source_directory.ensure('build', dir=True)
+        build_lib = build.ensure('lib', dir=True)
+        build_scripts = build.ensure('scripts-%s.%s' % VERSION_INFO, dir=True)
+        task = Build(
+            source=config.source_directory,
+            build_lib=build_lib,
+            build_scripts=build_scripts,
+        )
+        queue.add(task)
+        queue.run_all()
+

tests/cli/test_build.py

 import sys
 VERSION_INFO = tuple(sys.version_info[:2])
 
-from kij.commands.build import build_command
+from kij.commands.build import BuildCommand
+from kij.commands import kij_script
 from kij.task_queue import Queue
 
-def test_build_command(config, site, fullsource):
-    queue = Queue()
-    build_command(config, queue)
-    queue.run_all()
+def test_build_command(script, fullsource):
+    script.main(['kij', 'build'])
     build = fullsource.join('build')
     assert build.check()
     assert build.join('lib').check()

tests/conftest.py

+
 from sanescript.config import Config
 
+from kij.commands import kij_script
 
 def pytest_funcarg__site(request):
     tmpdir = request.getfuncargvalue('tmpdir')
     config.grab_from_dict(dict(
             site=site,
             source=source,
+            source_directory=source,
             ))
     return config
+
+def pytest_funcarg__script(request):
+    config = request.getfuncargvalue('config')
+    kij_script._config.grab_from_ns(config)
+    return kij_script
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.