old_contents: import os
  import sys
  from commands.apply_config import ApplyConfigCommand
  from commands.compile import CompileCommand
  from commands.init import InitCommand
  from commands.setup import SetupCommand
  from commands.update_deps import UpdateDepsCommand
  from lib.config import Config
  from lib.error import GoogkitError
  
  
  CONFIG = 'googkit.cfg'
  COMMANDS_DICT = {
          'apply-config': [ApplyConfigCommand, UpdateDepsCommand],
          'compile': [CompileCommand],
          'init': [InitCommand],
          'setup': [SetupCommand, UpdateDepsCommand],
          'update-deps': [UpdateDepsCommand]}
  
  
  def print_help():
      print('Usage: googkit command')
      print('')
      print('Available subcommands:')
  
      for name in sorted(COMMANDS_DICT.keys()):
          print('    ' + name)
  
  
  if __name__ == '__main__':
      if len(sys.argv) != 2:
          print_help()
          sys.exit()
  
      subcommand_classes = COMMANDS_DICT.get(sys.argv[1])
      if subcommand_classes is None:
          print_help()
          sys.exit()
  
      config = Config()
      try:
          config.load(CONFIG)
      except IOError:
          config = None
  
      try:
          for klass in subcommand_classes:
              subcommand = klass(config)
              subcommand.run()
      except GoogkitError, e:
          sys.exit('[ERROR] ' + str(e))
  
new_contents: import os
  import sys
  from commands.apply_config import ApplyConfigCommand
  from commands.compile import CompileCommand
  from commands.init import InitCommand
  from commands.setup import SetupCommand
  from commands.update_deps import UpdateDepsCommand
  from lib.config import Config
  from lib.error import GoogkitError
  
  
  CONFIG = 'googkit.cfg'
  COMMANDS_DICT = {
          'apply-config': [ApplyConfigCommand, UpdateDepsCommand],
          'compile': [CompileCommand],
          'init': [InitCommand],
          'setup': [SetupCommand, UpdateDepsCommand],
          'update-deps': [UpdateDepsCommand]}
  
  
  def print_help():
      print('Usage: googkit command')
      print('')
      print('Available subcommands:')
  
      for name in sorted(COMMANDS_DICT.keys()):
          print('    ' + name)
  
  
  if __name__ == '__main__':
      if len(sys.argv) != 2:
          print_help()
          sys.exit()
  
      subcommand_classes = COMMANDS_DICT.get(sys.argv[1])
      if subcommand_classes is None:
          print_help()
          sys.exit()
  
      config = Config()
      try:
          while os.path.exists(os.path.relpath(CONFIG)):
              before = os.getcwd()
              os.chdir('..')
  
              # Break if current dir is root.
              if before == os.getcwd():
                  break
  
          config.load(CONFIG)
      except IOError:
          config = None
  
      try:
          for klass in subcommand_classes:
              subcommand = klass(config)
              subcommand.run()
      except GoogkitError, e:
          sys.exit('[ERROR] ' + str(e))
  
subject: Support making available to exec cmd on sub dir