Skip to content

Commit 154e5a2

Browse files
committed
add support for subcomand in format <command>-<subcommand>
1 parent fbbb044 commit 154e5a2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

bin/cog-subcommand

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import os
55

66
bundle_name = os.getenv("COG_BUNDLE")
77
command_name = os.getenv("COG_COMMAND").split("-")[0]
8+
subcommand_name = os.getenv("COG_COMMAND").split("-")[1]
89
class_name = command_name.capitalize()
9-
full_path = "%s.commands.%s" % (bundle_name, command_name)
10+
subclass_name = subcommand_name.capitalize()
11+
12+
full_path = "%s.commands.%s.%s" % (bundle_name, command_name, subcommand_name)
1013

1114
bundle_module = importlib.import_module(full_path)
12-
klass = getattr(bundle_module, class_name)
15+
klass = getattr(bundle_module, subclass_name)
1316
cmd = klass()
1417
cmd.execute()

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
setup (
55
name = "pycog3",
6-
version = "0.1.27",
7-
scripts = ["bin/cog-command"],
6+
version = "0.1.28",
7+
scripts = ["bin/cog-command", "bin/cog-subcommand"],
88
description = "Command library for the Cog ChatOps platform for Python3",
99
author = "Kevin Smith",
1010
author_email = "kevin@operable.io",
1111
url = "https://github.com/cog-bundles/pycog3",
12-
download_url = "https://github.com/cog-bundles/pycog3/tarball/0.1.27",
12+
download_url = "https://github.com/cog-bundles/pycog3/tarball/0.1.28",
1313
packages = ["cog"],
1414
requires = ["requests (>=2.10)", "PyYAML (>=3.11)"],
1515
keywords = ["bot", "devops", "chatops", "automation"],

0 commit comments

Comments
 (0)