Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration of zuliprc location to a config directory #1503

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Commits on Aug 12, 2024

  1. Configuration menu
    Copy the full SHA
    59828e4 View commit details
    Browse the repository at this point in the history
  2. refactor: run: Split parse_zuliprc() to create a separate function.

    Created resolve_to_valid_path() to return a valid zuliprc path.
    Added docstring.
    Niloth-p committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    8d17aa9 View commit details
    Browse the repository at this point in the history
  3. refactor: run: Set zuliprc_path via login_and_save().

    Previously, zuliprc_path was set directly in main().
    Now, we are setting it 2 levels deeper, inside of login_and_save(),
    passing it to main() through resolve_to_valid_path().
    
    main() now sets the default value of zuliprc_path to None, and uses the
    returned path from resolve_to_valid_path().
    
    This is done to allow adding support for multiple zuliprc paths later,
    where we will dynamically compute the path in login_and_save(), after
    taking user input.
    Niloth-p committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    ebd394f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1bde5fd View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c0a0726 View commit details
    Browse the repository at this point in the history
  6. run: Use the new config directory as a default zuliprc path.

    In addition to the previous default path ~/zuliprc.
    
    Introduce the .config path of zulip-terminal as a str constant.
    
    Add a function check_for_default_zuliprc() to search for zuliprc files
    in both the default locations, when the --config-file argument is not
    used.
    
    It is added to ensure that users who have only a single account can
    skip using the account alias argument that will be added.
    
    Docstring updated.
    Tests updated.
    Niloth-p committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    d866880 View commit details
    Browse the repository at this point in the history
  7. run: Create account-wise zuliprc files in the new config path.

    Newly generated zuliprc files were being saved to `~/zuliprc`.
    This moves default zuliprc creation into the user's config directory.
    
    The --config-file option will no longer be able to save zuliprc files
    in custom locations.
    
    The new config path including the .config directory are handled safely,
    to allow creation even if they do not already exist.
    
    Tests updated.
    
    The test with id: `path_does_not_exist`, in the test function
    `test_main_cannot_write_zuliprc_given_good_credentials()` has been
    removed, as the path will now be created even if it does not exist.
    Niloth-p committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    a4038b2 View commit details
    Browse the repository at this point in the history

Commits on Aug 24, 2024

  1. run: Add new positional argument account-alias to load config.

    The usage of the account-alias positional argument is made mutually
    exclusive with the config-file option.
    Niloth-p committed Aug 24, 2024
    Configuration menu
    Copy the full SHA
    ffdd5ee View commit details
    Browse the repository at this point in the history
  2. run: Add new argument --list-accounts.

    Lists all the accounts in the config path, by checking the directory
    structure. The home path zuliprc is not considered in this list.
    
    Tests updated.
    Niloth-p committed Aug 24, 2024
    Configuration menu
    Copy the full SHA
    330d6c9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    27473c1 View commit details
    Browse the repository at this point in the history
  4. refactor: run: Stop passing zuliprc_path to login_and_save().

    Previously, we had to pass the zuliprc_path because the --config-file
    option could be used to create a zuliprc at a custom location.
    
    Now, all accounts are only saved to the standard config path. So, by
    moving the print statement to the outer function, we can simplify
    login_and_save().
    Niloth-p committed Aug 24, 2024
    Configuration menu
    Copy the full SHA
    817b46a View commit details
    Browse the repository at this point in the history
  5. run: Add new argument --new--account to create a new account.

    - If --new-account is used along with --config-file,
      - If the given path is valid, that zuliprc will be loaded
      - Else, a new account will be created, but not at the given path.
    - If --new-account is used along with account-alias, the new account
    argument will be ignored.
    
    Tests updated.
    Niloth-p committed Aug 24, 2024
    Configuration menu
    Copy the full SHA
    9681331 View commit details
    Browse the repository at this point in the history