Skip to content

cargo new --script #16849

@epage

Description

@epage

Problem

Overall, cargo script has been intended to be lightweight enough to not need cargo new support.

When we add support for workspaces, things will shift including

  • Opting in to workspace discovery (the proposed package.workspace = true)
  • Auto-inheriting

Proposed Solution

cargo new --script foo.rs to create

#!/usr/bin/env cargo
---
[package]
edition = "<current>"
---

fn main() {}

and when in a workspace:

#!/usr/bin/env cargo
---
[package]
edition = "<current>"
workspace = true
... any `workspace.package` fields
---

fn main() {}

Notes

Is --script the right name?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-workspacesArea: workspacesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-newS-triageStatus: This issue is waiting on initial triage.Z-scriptNightly: cargo script

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions