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

feat: CLI attach preview task running in the language server #1235

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/tinymist/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub enum Commands {
/// Runs language server for tracing some typst program.
#[clap(hide(true))]
TraceLsp(TraceLspArgs),
/// Attaches a preview task running in the language server.
#[cfg(feature = "preview")]
AttachPreview(tinymist::tool::preview::AttachPreviewArgs),
/// Runs preview server
#[cfg(feature = "preview")]
Preview(tinymist::tool::preview::PreviewCliArgs),
Expand Down
4 changes: 4 additions & 0 deletions crates/tinymist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ fn main() -> Result<()> {
Commands::Lsp(args) => lsp_main(args),
Commands::TraceLsp(args) => trace_lsp_main(args),
#[cfg(feature = "preview")]
Commands::AttachPreview(args) => {
panic!("implement attach preview {args:?}")
}
#[cfg(feature = "preview")]
Commands::Preview(args) => {
#[cfg(feature = "preview")]
use tinymist::tool::preview::preview_main;
Expand Down
24 changes: 24 additions & 0 deletions crates/tinymist/src/tool/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ impl typst_preview::CompileView for PreviewCompileView {
}
}

/// CLI Arguments for attaching a preview in background.
#[derive(Debug, Clone, clap::Parser)]
pub struct AttachPreviewArgs {
/// The target to attach to.
///
/// ## Example
///
/// Selects a target interactively. If there is only one target, it will be
/// selected automatically.
///
/// ```
/// tinymist attach-preview
/// ```
///
/// ## Example
///
/// Attach to a preview server running on port 23333.
///
/// ```
/// tinymist attach-preview port:23333
/// ```
pub target: Option<String>,
}

/// CLI Arguments for the preview tool.
#[derive(Debug, Clone, clap::Parser)]
pub struct PreviewCliArgs {
Expand Down
Loading