-
Notifications
You must be signed in to change notification settings - Fork 20
fix: unify colour resolution behind a terminal profile #94
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,28 @@ impl From<ShellArg> for Shell { | |
| } | ||
| } | ||
|
|
||
| /// Which terminal profile a session runs with. | ||
| #[derive(Args, Clone, Default)] | ||
| pub struct ProfileArgs { | ||
| /// Config file to read (default: ./shell-use.toml, then | ||
| /// ~/.shell-use/shell-use.toml). | ||
| #[arg(long, value_name = "PATH")] | ||
| pub config: Option<std::path::PathBuf>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are adding a config, we should add some validation to it, ex: validating that we are getting valid colors for the profile so we don't have random crashes |
||
| /// Named profile from the config file (default: `default`). | ||
| #[arg(long, value_name = "NAME")] | ||
| pub profile: Option<String>, | ||
| } | ||
|
|
||
| impl ProfileArgs { | ||
| /// Resolve to concrete settings. Done here, in the client, because the | ||
| /// daemon is long-lived and shared and so has no working directory to | ||
| /// resolve a project-local config against. | ||
| pub fn resolve(&self) -> anyhow::Result<shell_use::profile::Profile> { | ||
| let cwd = std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from(".")); | ||
| shell_use::profile::resolve(self.config.as_deref(), self.profile.as_deref(), &cwd) | ||
| } | ||
| } | ||
|
|
||
| /// Per-class default timeouts for a session, in milliseconds. | ||
| #[derive(Args, Clone, Copy, Default)] | ||
| pub struct TimeoutArgs { | ||
|
|
@@ -114,6 +136,8 @@ pub enum Command { | |
| #[arg(long, conflicts_with = "wait_ready")] | ||
| no_wait_ready: bool, | ||
| #[command(flatten)] | ||
| profile: ProfileArgs, | ||
| #[command(flatten)] | ||
| timeouts: TimeoutArgs, | ||
| }, | ||
| /// Spawn a session running a program directly. | ||
|
|
@@ -143,6 +167,8 @@ pub enum Command { | |
| #[arg(long, conflicts_with = "wait_ready")] | ||
| no_wait_ready: bool, | ||
| #[command(flatten)] | ||
| profile: ProfileArgs, | ||
| #[command(flatten)] | ||
| timeouts: TimeoutArgs, | ||
| }, | ||
| /// Close the current session (or all sessions). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also honor XDG_CACHE_HOME if we are adding a configuration file