code: def main(argv=None):
      if argv is None:
          argv = sys.argv[1:]
      parser = build_args()
      args = parser.parse_args(args=argv)
      recipe_name, _ext = os.path.splitext(os.path.basename(args.recipe))
      rm = RecipeManager()
      rm.add_recipe_folder(os.path.dirname(args.recipe), whitelist=[os.path.basename(args.recipe)])
      recipe = rm.get_recipe(recipe_name)
      if args.archive is not None:
          print("Archiving recipe into %s" % args.archive)
          recipe.archive(args.archive)
          return 0
      if args.info:
          print(recipe)
          return 0
      variables = load_variables(args.define, args.config)
      success = 0
      start_time = time.time()
      if args.loop is None:
          try:
              recipe.run(variables)
              success += 1
          except IOTileException as exc:
              print("Error running recipe: %s" % str(exc))
              return 1
      else:
          while True:
              value = input("Enter value for loop variable %s (return to stop): " % args.loop)
              if value == '':
                  break
              local_vars = dict(**variables)
              local_vars[args.loop] = value
              try:
                  recipe.run(local_vars)
                  success += 1
              except IOTileException as exc:
                  print("--> ERROR processing loop variable %s: %s" % (value, str(exc)))
      end_time = time.time()
      total_time = end_time - start_time
      if success == 0:
          per_time = 0.0
      else:
          per_time = total_time / success
      print("Performed %d runs in %.1f seconds (%.1f seconds / run)" % (success, total_time, per_time))
      return 0