-
Notifications
You must be signed in to change notification settings - Fork 478
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
cli: add play cmd #2242
base: master
Are you sure you want to change the base?
cli: add play cmd #2242
Conversation
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.
nice! Can you add a line to next.md and also update the man page as well?
@@ -38,6 +39,7 @@ Subcommands: | |||
%[1]s layout [name] - Display long help for a particular layout engine, including its configuration options | |||
%[1]s themes - Lists available themes | |||
%[1]s fmt file.d2 ... - Format passed files | |||
%[1]s play file.d2 - Opens the file in playground |
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.
playground
might be unknown to folks. I'd add a description like Opens the file in the d2 playground, an online web viewer
@@ -154,6 +154,8 @@ func Run(ctx context.Context, ms *xmain.State) (err error) { | |||
return nil | |||
case "fmt": | |||
return fmtCmd(ctx, ms) | |||
case "play": | |||
return playSubcommand(ctx, ms) |
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.
playCmd
to conform with above naming standards
if len(ms.Opts.Flags.Args()) != 2 { | ||
return xmain.UsageErrorf("play must be passed one file to open") | ||
} |
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.
it should also allow stdin
return err | ||
} | ||
|
||
url := fmt.Sprintf("https://play.d2lang.com/?l=&script=%s&sketch=%d&theme=%d&", encoded, sketchNumber, theme) |
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.
what's the l=
?
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.
This was in the URL provided in the issue. I'll remove.
I'm assuming you'd consider this a feature? Or should I put it under improvements? |
yeah that's a feature |
Fix #1213 - Added play command to cli that opens the playground with the given diagram, theme and sketch flag.