Exemplo n.º 1
0
 def Run(self, args):
   if args.devsite_dir:
     walker_util.DevSiteGenerator(self._cli_power_users_only,
                                  args.devsite_dir).Walk(
                                      args.hidden, args.restrict)
   if args.help_text_dir:
     walker_util.HelpTextGenerator(
         self._cli_power_users_only, args.help_text_dir).Walk(args.hidden,
                                                              args.restrict)
   if args.html_dir:
     walker_util.HtmlGenerator(
         self._cli_power_users_only, args.html_dir).Walk(args.hidden,
                                                         args.restrict)
     tree = walker_util.CommandTreeGenerator(
         self._cli_power_users_only).Walk(args.hidden, args.restrict)
     with io.open(os.path.join(args.html_dir, '_menu_.html'), 'wt') as out:
       WriteHtmlMenu(tree, out)
     for file_name in _HELP_HTML_DATA_FILES:
       with io.open(os.path.join(args.html_dir, file_name), 'wb') as out:
         file_contents = pkg_resources.GetResource(
             'googlecloudsdk.api_lib.meta.help_html_data.', file_name)
         out.write(file_contents)
   if args.manpage_dir:
     walker_util.ManPageGenerator(
         self._cli_power_users_only, args.manpage_dir).Walk(args.hidden,
                                                            args.restrict)
   if args.update_help_text_dir:
     # The help text golden files are always ascii.
     console_attr.ResetConsoleAttr(encoding='ascii')
     changes = help_util.HelpTextUpdater(
         self._cli_power_users_only, args.update_help_text_dir,
         test=args.test).Update(args.restrict)
     if changes and args.test:
       raise HelpTextOutOfDateError('Help text files must be updated.')
Exemplo n.º 2
0
 def Run(self, args):
     if args.devsite_dir:
         walker_util.DevSiteGenerator(self.cli, args.devsite_dir).Walk(
             args.hidden, args.restrict)
     if args.help_text_dir:
         walker_util.HelpTextGenerator(self.cli, args.help_text_dir).Walk(
             args.hidden, args.restrict)
     if args.html_dir:
         walker_util.HtmlGenerator(self.cli, args.html_dir).Walk(
             args.hidden, args.restrict)
         tree = walker_util.CommandTreeGenerator(self.cli).Walk(
             args.hidden, args.restrict)
         with open(os.path.join(args.html_dir, '_menu_.html'), 'w') as out:
             WriteHtmlMenu(tree, out)
         for file_name in _HELP_HTML_DATA_FILES:
             with open(os.path.join(args.html_dir, file_name), 'wb') as out:
                 file_contents = pkg_resources.GetResource(
                     'googlecloudsdk.api_lib.meta.help_html_data.',
                     file_name)
                 out.write(file_contents)
     if args.manpage_dir:
         walker_util.ManPageGenerator(self.cli, args.manpage_dir).Walk(
             args.hidden, args.restrict)
     if args.update_help_text_dir:
         changes = help_util.HelpTextUpdater(self.cli,
                                             args.update_help_text_dir,
                                             test=args.test).Update()
         if changes and args.test:
             raise HelpTextOutOfDateError(
                 'Help text files must be updated.')
Exemplo n.º 3
0
 def Run(self, args):
     if args.completions:
         args.flags = True
         args.flag_values = True
         args.hidden = True
     return walker_util.CommandTreeGenerator(
         self.cli, with_flags=args.flags,
         with_flag_values=args.flag_values).Walk(args.hidden, args.restrict)
Exemplo n.º 4
0
 def testCommandTreeGeneratorWithFlagValues(self):
   """Test the resource of all groups and commands with flags/flag values."""
   result = walker_util.CommandTreeGenerator(self.cli,
                                             with_flag_values=True).Walk()
   global_flags = result['_flags_']
   self.assertIn('--document=:dict:', global_flags)
   self.assertIn('--help', global_flags)
   self.assertIn('--verbosity=critical,debug,error,info,none,warning',
                 global_flags)
Exemplo n.º 5
0
  def testCommandTreeGeneratorHiddenRestrict(self):
    """Test the list of the restricted hidden sdk groups and commands."""
    result = walker_util.CommandTreeGenerator(self.cli).Walk(
        hidden=True, restrict=['gcloud.sdk'])
    resource_printer.Print(result, print_format='json')
    self.AssertOutputContains("""\
{
  "_name_": "gcloud",
  "groups": [
    {
      "_name_": "sdk",
      "commands": [
        {
          "_name_": "hidden-command"
        },
        {
          "_name_": "ordered-choices"
        },
        {
          "_name_": "second-level-command-1"
        },
        {
          "_name_": "second-level-command-b"
        },
        {
          "_name_": "xyzzy"
        }
      ],
      "groups": [
        {
          "_name_": "hiddengroup",
          "commands": [
            {
              "_name_": "hidden-command-2"
            },
            {
              "_name_": "hidden-command-a"
            }
          ]
        },
        {
          "_name_": "subgroup",
          "commands": [
            {
              "_name_": "subgroup-command-2"
            },
            {
              "_name_": "subgroup-command-a"
            }
          ]
        }
      ]
    }
  ]
}
""")
 def GenerateHtmlNav(directory):
     """Generates html nav files in directory."""
     tree = walker_util.CommandTreeGenerator(
         self._cli_power_users_only).Walk(args.hidden, args.restrict)
     with files.FileWriter(os.path.join(directory,
                                        '_menu_.html')) as out:
         WriteHtmlMenu(tree, out)
     for file_name in _HELP_HTML_DATA_FILES:
         file_contents = pkg_resources.GetResource(
             'googlecloudsdk.api_lib.meta.help_html_data.', file_name)
         files.WriteBinaryFileContents(
             os.path.join(directory, file_name), file_contents)
Exemplo n.º 7
0
 def Run(self, args):
     if args.devsite_dir:
         walker_util.DevSiteGenerator(self.cli, args.devsite_dir).Walk(
             args.hidden, args.restrict)
     if args.html_dir:
         walker_util.HtmlGenerator(self.cli, args.html_dir).Walk(
             args.hidden, args.restrict)
         tree = walker_util.CommandTreeGenerator(self.cli).Walk(
             args.hidden, args.restrict)
         with open(os.path.join(args.html_dir, '_menu_.html'), 'w') as out:
             WriteHtmlMenu(tree, out)
         for file_name in _HELP_HTML_DATA_FILES:
             with open(os.path.join(args.html_dir, file_name), 'wb') as out:
                 file_contents = pkg_resources.GetResource(
                     'googlecloudsdk.api_lib.meta.help_html_data.',
                     file_name)
                 out.write(file_contents)
     if args.manpage_dir:
         walker_util.ManPageGenerator(self.cli, args.manpage_dir).Walk(
             args.hidden, args.restrict)
Exemplo n.º 8
0
  def testCommandTreeGeneratorAllFlagsValues(self):
    """Test the list of all groups and commands with flags and flag values."""
    result = walker_util.CommandTreeGenerator(self.cli,
                                              with_flag_values=True).Walk()
    resource_printer.Print(result, print_format='json')
    self.AssertOutputContains("""\
{
  "_flags_": [
    "---flag-file-line-=:FLAG_FILE_LINE_:",
    "--authority-selector=:AUTHORITY_SELECTOR:",
    "--authorization-token-file=:AUTHORIZATION_TOKEN_FILE:",
    "--configuration=:CONFIGURATION:",
    "--credential-file-override=:CREDENTIAL_FILE_OVERRIDE:",
    "--document=:dict:",
    "--flags-file=:YAML_FILE:",
    "--flatten=:list:",
    "--format=:FORMAT:",
    "--help",
    "--http-timeout=:HTTP_TIMEOUT:",
    "--log-http",
    "--user-output-enabled",
    "--verbosity=critical,debug,error,info,none,warning",
    "-h"
  ],
  "_name_": "gcloud",
  "commands": [
    {
      "_name_": "version"
    }
  ],
  "groups": [
    {
      "_name_": "alpha",
      "commands": [
        {
          "_name_": "version"
        }
      ],
      "groups": [
        {
          "_name_": "internal",
          "commands": [
            {
              "_name_": "internal-command"
            }
          ]
        },
        {
          "_name_": "sdk",
          "commands": [
            {
              "_flags_": [
                "--ordered-choices=a-100g,a-10g,a-1g"
              ],
              "_name_": "ordered-choices"
            },
            {
              "_name_": "second-level-command-1"
            },
            {
              "_name_": "second-level-command-b"
            },
            {
              "_flags_": [
                "--exactly-one=:STOOGE:",
                "--exactly-three=:STOOGE:",
                "--hidden",
                "--one-or-more=:ATTRIBUTE:",
                "--zero-or-more=:ZERO_OR_MORE:",
                "--zero-or-one=:ZERO_OR_ONE:"
              ],
              "_name_": "xyzzy"
            }
          ],
          "groups": [
            {
              "_name_": "alphagroup"
            },
            {
              "_name_": "subgroup",
              "commands": [
                {
                  "_name_": "subgroup-command-2"
                },
                {
                  "_flags_": [
                    "--delete-in=:DELETE_IN:",
                    "--delete-on=:DELETE_ON:",
                    "--obsolete-in=:OBSOLETE_IN:",
                    "--obsolete-on=:OBSOLETE_ON:"
                  ],
                  "_name_": "subgroup-command-a"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "_name_": "beta",
      "commands": [
        {
          "_name_": "version"
        }
      ],
      "groups": [
        {
          "_name_": "internal",
          "commands": [
            {
              "_name_": "internal-command"
            }
          ]
        },
        {
          "_name_": "sdk",
          "commands": [
            {
              "_flags_": [
                "--ordered-choices=a-100g,a-10g,a-1g"
              ],
              "_name_": "ordered-choices"
            },
            {
              "_name_": "second-level-command-1"
            },
            {
              "_name_": "second-level-command-b"
            },
            {
              "_flags_": [
                "--exactly-one=:STOOGE:",
                "--exactly-three=:STOOGE:",
                "--hidden",
                "--one-or-more=:ATTRIBUTE:",
                "--zero-or-more=:ZERO_OR_MORE:",
                "--zero-or-one=:ZERO_OR_ONE:"
              ],
              "_name_": "xyzzy"
            }
          ],
          "groups": [
            {
              "_flags_": [
                "--location=:LOCATION:"
              ],
              "_name_": "betagroup",
              "commands": [
                {
                  "_flags_": [
                    "--location=:LOCATION:"
                  ],
                  "_name_": "beta-command"
                },
                {
                  "_flags_": [
                    "--location=:LOCATION:"
                  ],
                  "_name_": "sub-command-2"
                },
                {
                  "_flags_": [
                    "--location=:LOCATION:",
                    "--one-two-three=1,2,3",
                    "--resourceful=:RESOURCEFUL:"
                  ],
                  "_name_": "sub-command-a"
                }
              ]
            },
            {
              "_name_": "subgroup",
              "commands": [
                {
                  "_name_": "subgroup-command-2"
                },
                {
                  "_flags_": [
                    "--delete-in=:DELETE_IN:",
                    "--delete-on=:DELETE_ON:",
                    "--obsolete-in=:OBSOLETE_IN:",
                    "--obsolete-on=:OBSOLETE_ON:"
                  ],
                  "_name_": "subgroup-command-a"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "_name_": "internal",
      "commands": [
        {
          "_name_": "internal-command"
        }
      ]
    },
    {
      "_name_": "sdk",
      "commands": [
        {
          "_flags_": [
            "--ordered-choices=a-100g,a-10g,a-1g"
          ],
          "_name_": "ordered-choices"
        },
        {
          "_name_": "second-level-command-1"
        },
        {
          "_name_": "second-level-command-b"
        },
        {
          "_flags_": [
            "--exactly-one=:STOOGE:",
            "--exactly-three=:STOOGE:",
            "--hidden",
            "--one-or-more=:ATTRIBUTE:",
            "--zero-or-more=:ZERO_OR_MORE:",
            "--zero-or-one=:ZERO_OR_ONE:"
          ],
          "_name_": "xyzzy"
        }
      ],
      "groups": [
        {
          "_name_": "subgroup",
          "commands": [
            {
              "_name_": "subgroup-command-2"
            },
            {
              "_flags_": [
                "--delete-in=:DELETE_IN:",
                "--delete-on=:DELETE_ON:",
                "--obsolete-in=:OBSOLETE_IN:",
                "--obsolete-on=:OBSOLETE_ON:"
              ],
              "_name_": "subgroup-command-a"
            }
          ]
        }
      ]
    }
  ]
}
""")
Exemplo n.º 9
0
 def testCommandTreeGeneratorNoFlags(self):
   """Test the resource of all groups and commands with flags."""
   result = walker_util.CommandTreeGenerator(self.cli).Walk()
   self.assertNotIn('_flags_', result)
Exemplo n.º 10
0
  def testCommandTreeGeneratorAllFlags(self):
    """Test the list of all groups and commands with flags."""
    result = walker_util.CommandTreeGenerator(self.cli, with_flags=True).Walk()
    resource_printer.Print(result, print_format='json')
    self.AssertOutputContains("""\
{
  "_flags_": [
    "---flag-file-line-",
    "--authority-selector",
    "--authorization-token-file",
    "--configuration",
    "--credential-file-override",
    "--document",
    "--flags-file",
    "--flatten",
    "--format",
    "--help",
    "--http-timeout",
    "--log-http",
    "--user-output-enabled",
    "--verbosity",
    "-h"
  ],
  "_name_": "gcloud",
  "commands": [
    {
      "_name_": "version"
    }
  ],
  "groups": [
    {
      "_name_": "alpha",
      "commands": [
        {
          "_name_": "version"
        }
      ],
      "groups": [
        {
          "_name_": "internal",
          "commands": [
            {
              "_name_": "internal-command"
            }
          ]
        },
        {
          "_name_": "sdk",
          "commands": [
            {
              "_flags_": [
                "--ordered-choices"
              ],
              "_name_": "ordered-choices"
            },
            {
              "_name_": "second-level-command-1"
            },
            {
              "_name_": "second-level-command-b"
            },
            {
              "_flags_": [
                "--exactly-one",
                "--exactly-three",
                "--hidden",
                "--one-or-more",
                "--zero-or-more",
                "--zero-or-one"
              ],
              "_name_": "xyzzy"
            }
          ],
          "groups": [
            {
              "_name_": "alphagroup"
            },
            {
              "_name_": "subgroup",
              "commands": [
                {
                  "_name_": "subgroup-command-2"
                },
                {
                  "_flags_": [
                    "--delete-in",
                    "--delete-on",
                    "--obsolete-in",
                    "--obsolete-on"
                  ],
                  "_name_": "subgroup-command-a"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "_name_": "beta",
      "commands": [
        {
          "_name_": "version"
        }
      ],
      "groups": [
        {
          "_name_": "internal",
          "commands": [
            {
              "_name_": "internal-command"
            }
          ]
        },
        {
          "_name_": "sdk",
          "commands": [
            {
              "_flags_": [
                "--ordered-choices"
              ],
              "_name_": "ordered-choices"
            },
            {
              "_name_": "second-level-command-1"
            },
            {
              "_name_": "second-level-command-b"
            },
            {
              "_flags_": [
                "--exactly-one",
                "--exactly-three",
                "--hidden",
                "--one-or-more",
                "--zero-or-more",
                "--zero-or-one"
              ],
              "_name_": "xyzzy"
            }
          ],
          "groups": [
            {
              "_flags_": [
                "--location"
              ],
              "_name_": "betagroup",
              "commands": [
                {
                  "_flags_": [
                    "--location"
                  ],
                  "_name_": "beta-command"
                },
                {
                  "_flags_": [
                    "--location"
                  ],
                  "_name_": "sub-command-2"
                },
                {
                  "_flags_": [
                    "--location",
                    "--one-two-three",
                    "--resourceful"
                  ],
                  "_name_": "sub-command-a"
                }
              ]
            },
            {
              "_name_": "subgroup",
              "commands": [
                {
                  "_name_": "subgroup-command-2"
                },
                {
                  "_flags_": [
                    "--delete-in",
                    "--delete-on",
                    "--obsolete-in",
                    "--obsolete-on"
                  ],
                  "_name_": "subgroup-command-a"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "_name_": "internal",
      "commands": [
        {
          "_name_": "internal-command"
        }
      ]
    },
    {
      "_name_": "sdk",
      "commands": [
        {
          "_flags_": [
            "--ordered-choices"
          ],
          "_name_": "ordered-choices"
        },
        {
          "_name_": "second-level-command-1"
        },
        {
          "_name_": "second-level-command-b"
        },
        {
          "_flags_": [
            "--exactly-one",
            "--exactly-three",
            "--hidden",
            "--one-or-more",
            "--zero-or-more",
            "--zero-or-one"
          ],
          "_name_": "xyzzy"
        }
      ],
      "groups": [
        {
          "_name_": "subgroup",
          "commands": [
            {
              "_name_": "subgroup-command-2"
            },
            {
              "_flags_": [
                "--delete-in",
                "--delete-on",
                "--obsolete-in",
                "--obsolete-on"
              ],
              "_name_": "subgroup-command-a"
            }
          ]
        }
      ]
    }
  ]
}
""")
Exemplo n.º 11
0
  def testCommandTreeGeneratorAll(self):
    """Test the list of all groups and commands."""
    result = walker_util.CommandTreeGenerator(self.cli).Walk()
    resource_printer.Print(result, print_format='json')
    self.AssertOutputContains("""\
{
  "_name_": "gcloud",
  "commands": [
    {
      "_name_": "version"
    }
  ],
  "groups": [
    {
      "_name_": "alpha",
      "commands": [
        {
          "_name_": "version"
        }
      ],
      "groups": [
        {
          "_name_": "internal",
          "commands": [
            {
              "_name_": "internal-command"
            }
          ]
        },
        {
          "_name_": "sdk",
          "commands": [
            {
              "_name_": "ordered-choices"
            },
            {
              "_name_": "second-level-command-1"
            },
            {
              "_name_": "second-level-command-b"
            },
            {
              "_name_": "xyzzy"
            }
          ],
          "groups": [
            {
              "_name_": "alphagroup"
            },
            {
              "_name_": "subgroup",
              "commands": [
                {
                  "_name_": "subgroup-command-2"
                },
                {
                  "_name_": "subgroup-command-a"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "_name_": "beta",
      "commands": [
        {
          "_name_": "version"
        }
      ],
      "groups": [
        {
          "_name_": "internal",
          "commands": [
            {
              "_name_": "internal-command"
            }
          ]
        },
        {
          "_name_": "sdk",
          "commands": [
            {
              "_name_": "ordered-choices"
            },
            {
              "_name_": "second-level-command-1"
            },
            {
              "_name_": "second-level-command-b"
            },
            {
              "_name_": "xyzzy"
            }
          ],
          "groups": [
            {
              "_name_": "betagroup",
              "commands": [
                {
                  "_name_": "beta-command"
                },
                {
                  "_name_": "sub-command-2"
                },
                {
                  "_name_": "sub-command-a"
                }
              ]
            },
            {
              "_name_": "subgroup",
              "commands": [
                {
                  "_name_": "subgroup-command-2"
                },
                {
                  "_name_": "subgroup-command-a"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "_name_": "internal",
      "commands": [
        {
          "_name_": "internal-command"
        }
      ]
    },
    {
      "_name_": "sdk",
      "commands": [
        {
          "_name_": "ordered-choices"
        },
        {
          "_name_": "second-level-command-1"
        },
        {
          "_name_": "second-level-command-b"
        },
        {
          "_name_": "xyzzy"
        }
      ],
      "groups": [
        {
          "_name_": "subgroup",
          "commands": [
            {
              "_name_": "subgroup-command-2"
            },
            {
              "_name_": "subgroup-command-a"
            }
          ]
        }
      ]
    }
  ]
}
""")
Exemplo n.º 12
0
 def Run(self, args):
   return walker_util.CommandTreeGenerator(self.cli).Walk(args.hidden,
                                                          args.restrict)
Exemplo n.º 13
0
 def Run(self, args):
   return walker_util.CommandTreeGenerator(
       self.cli, with_flags=args.flags,
       with_flag_values=args.flag_values).Walk(args.hidden, args.restrict)