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

Add support for multiple workspaces #169

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

j6k4m8
Copy link

@j6k4m8 j6k4m8 commented Nov 13, 2018

This adds (backwards-semi-incompatible) support for multi-workspace:

Set up a new workspaces lookup in your config:

{
    "workspaces": {
        "work": {
            "slack_token": "xoxp..."
        },
        "friends": {
            "slack_token": "xoxp...",
            "notify": "all"
        },
    },
    // All existing configs
}

Then invoke with:

slack-term -workspace friends

All options (except for workspaces itself) can also be specified in each workspace config, except for emoji which I'm not sure how to check for in this implementation. (Thoughts welcome!)

If you do not specify a -workspace flag, the first one (alphabetically) will be selected. This is nice for invoking in cases where users have only a single workspace, and is a sane default otherwise.

See #46 for earlier discussion.

Copy link

@frzifus frzifus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@aakropotkin
Copy link

aakropotkin commented May 9, 2019

I just installed this it's fantastic! Thank you!
The only suggestion I would make is to make the "workspaces" object optional for backwards compatibility. If this got merged into master and folks updated, they would crash and need to head over to github to learn about the change.
If you still accept the old tag you don't break folks configs, or alternatively have it print a descriptive message if "workspaces" is missing.

Thank you for your hard work this is a fantastic addition!

A keymap to change workspaces is a logical extension, I might take a crack at that.

I wrapped mine is a zsh script to prompt for the workspace:

function slack-term() {
  if [[ $# -lt 1 ]]; then
    read "workspace?Which workspace: (`jq -r '.workspaces | keys | @csv' $HOME/.slack-term | sed 's/"//g' | sed 's/,/\|/g'`) ? "
  else
    workspace=${1}
  fi
  command slack-term -workspace $workspace
}

Ex: Which workspace: (work|friends) ?

@j6k4m8
Copy link
Author

j6k4m8 commented Sep 4, 2019

@alexameen roger that! I'll try to get a fix for this in shortly.

@erroneousboat would you be interested in a slack-term list-workspaces command?

@jpbruinsslot
Copy link
Owner

jpbruinsslot commented Sep 7, 2019

At the moment I don't see the advantage of this, instead of using multiple configuration files. Only that you have one config file.

@j6k4m8
Copy link
Author

j6k4m8 commented Mar 19, 2020

@erroneousboat The advantage is that you can share settings across workspaces instead of needing to edit each file independently. But happy to leave this as a fork and close the PR if you prefer!

@j6k4m8 j6k4m8 mentioned this pull request Nov 6, 2020
@gshpychka
Copy link

@erroneousboat Do you still believe that copy-pasting configs between workspaces, and having to edit them in five places every time you need to change something is a good idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants