예제 #1
0
파일: app.py 프로젝트: jaczhan/azure-cli
from azure.cli.core._config import az_config, DEFAULTS_SECTION
from azure.cli.core._environment import get_config_dir
from azure.cli.core._profile import _SUBSCRIPTION_NAME, Profile
from azure.cli.core._session import ACCOUNT, CONFIG, SESSION
from azure.cli.core.util import (show_version_info_exit, handle_exception)
from azure.cli.core.util import CLIError

SHELL_CONFIGURATION = azclishell.configuration.CONFIGURATION
SHELL_CONFIG_DIR = azclishell.configuration.get_config_dir

NOTIFICATIONS = ""
PROFILE = Profile()
SELECT_SYMBOL = azclishell.configuration.SELECT_SYMBOL
PART_SCREEN_EXAMPLE = .3
START_TIME = datetime.datetime.utcnow()
CLEAR_WORD = get_os_clear_screen_word()


def handle_cd(cmd):
    """changes dir """
    if len(cmd) != 2:
        print("Invalid syntax: cd path")
        return
    path = os.path.expandvars(os.path.expanduser(cmd[1]))
    try:
        os.chdir(path)
    except OSError as ex:
        print("cd: %s\n" % ex)


def space_examples(list_examples, rows):
예제 #2
0
from azure.cli.core._profile import _SUBSCRIPTION_NAME, Profile
from azure.cli.core._session import ACCOUNT, CONFIG, SESSION
import azure.cli.core.telemetry as cli_telemetry
from azure.cli.core.util import (show_version_info_exit, handle_exception)
from azure.cli.core.util import CLIError


SHELL_CONFIGURATION = azclishell.configuration.CONFIGURATION
SHELL_CONFIG_DIR = azclishell.configuration.get_config_dir

NOTIFICATIONS = ""
PROFILE = Profile()
SELECT_SYMBOL = azclishell.configuration.SELECT_SYMBOL
PART_SCREEN_EXAMPLE = .3
START_TIME = datetime.datetime.utcnow()
CLEAR_WORD = get_os_clear_screen_word()


def space_examples(list_examples, rows):
    """ makes the example text """
    examples_with_index = []

    for i, _ in list(enumerate(list_examples)):
        examples_with_index.append("[" + str(i + 1) + "] " + list_examples[i][0] +
                                   list_examples[i][1])

    example = "".join(exam for exam in examples_with_index)
    num_newline = example.count('\n')

    page_number = ''
    if num_newline > rows * PART_SCREEN_EXAMPLE: