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 tmt about, command showing things about tmt itself #3470

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

happz
Copy link
Collaborator

@happz happz commented Jan 16, 2025

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • include a release note

@happz happz added the code | cli Changes related to the command line interface label Jan 16, 2025
@happz happz added this to the 1.43 milestone Jan 16, 2025
@psss
Copy link
Collaborator

psss commented Jan 17, 2025

This sounds like a very nice idea! Are there any limitations about the usage? I tried the new command within the venv but I get no output.

@happz
Copy link
Collaborator Author

happz commented Jan 17, 2025

This sounds like a very nice idea! Are there any limitations about the usage? I tried the new command within the venv but I get no output.

$ tmt about plugins --how rest
Export plugins for story

* `dict`
* `json`
* `template`
* `rst`
* `yaml`

----

Export plugins for plan

* `dict`
* `json`
* `template`
* `yaml`

----
...

$ tmt about plugins --how json | jq .
{
  "export.story": [
    "dict",
    "json",
    "template",
    "rst",
    "yaml"
  ],
  "export.plan": [
    "dict",
    "json",
    "template",
    "yaml"
  ],
  "export.test": [
    "dict",
    ...

The current limitation is, it's just listing plugins, nothing more. I hope to get it to share more info, maybe render plugin docs, specs docs, or explanation of various errors, just like rustc --explain does:

$ PAGER= rustc --explain E0277
You tried to use a type which doesn't implement some trait in a place which expected that trait.

Erroneous code example:

// here we declare the Foo trait with a bar method
trait Foo {
    fn bar(&self);
}

// we now declare a function which takes an object implementing the Foo trait
fn some_func<T: Foo>(foo: T) {
    foo.bar();
}

fn main() {
    // we now call the method with the i32 type, which doesn't implement
    // the Foo trait
    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied
}

In order to fix this error, verify that the type you're using does implement the trait. Example:

trait Foo {
    fn bar(&self);
}

// we implement the trait on the i32 type
impl Foo for i32 {
    fn bar(&self) {}
}

fn some_func<T: Foo>(foo: T) {
    foo.bar(); // we can now use this method since i32 implements the
               // Foo trait
}

fn main() {
    some_func(5i32); // ok!
}

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code | cli Changes related to the command line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants