Skip to content

add a download command #12

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

Merged
merged 2 commits into from
Oct 13, 2023
Merged

add a download command #12

merged 2 commits into from
Oct 13, 2023

Conversation

amtoine
Copy link
Member

@amtoine amtoine commented Oct 12, 2023

related to

description

i was playing with the nightly builds of Nushell in nushell/nupm#29 and wrote a little script to download the latest build automatically 😋

i think the easiest is to read the new section in the README 😉

@amtoine amtoine requested a review from hustcer October 12, 2023 07:52
@hustcer
Copy link
Contributor

hustcer commented Oct 13, 2023

Good idea, I will try it later, thanks

@hustcer hustcer merged commit 748950c into nushell:nightly Oct 13, 2023
@hustcer
Copy link
Contributor

hustcer commented Oct 13, 2023

Thanks for adding this feature, one more thing: it might not that helpful for the Windows users:

 λ $> tk get-latest-nightly-build
Please choose one architecture: |
  aarch64-apple-darwin
  aarch64-darwin-full
  aarch64-linux-gnu-full
  aarch64-pc-windows-msvc
  aarch64-pc-windows-msvc
  aarch64-unknown-linux-gnu
> aarch64-windows-msvc-full
  aarch64-windows-msvc-full
  armv7-unknown-linux-gnueabihf
  riscv64gc-unknown-linux-gnu
  x86_64-apple-darwin
  x86_64-darwin-full
  x86_64-linux-gnu-full
  x86_64-linux-musl-full
  x86_64-pc-windows-msvc
  x86_64-pc-windows-msvc
  x86_64-unknown-linux-gnu
  x86_64-unknown-linux-musl
  x86_64-windows-msvc-full
  x86_64-windows-msvc-full

as there are always two packages with the same name for each target, no matter which one I choose will get an error:

Error:   × unexpected_internal_error:
  │ expected one match, found 2
  │ matches: [{url: https://api.github.com/repos/nushell/nightly/releases/assets/130351362, id: 130351362, node_id:
  │ RA_kwDOJuqqcM4HxQEC, name: nu-0.85.1-aarch64-pc-windows-msvc.msi, label: , uploader: {login: github-actions[bot], id:
  │ 41898282, node_id: MDM6Qm90NDE4OTgyODI=, avatar_url: https://avatars.githubusercontent.com/in/15368?v=4, gravatar_id: ,
  │ url: https://api.github.com/users/github-actions%5Bbot%5D, html_url: https://github.com/apps/github-actions,
  │ followers_url: https://api.github.com/users/github-actions%5Bbot%5D/followers, following_url: https://api.github.com/
  │ users/github-actions%5Bbot%5D/following{/other_user}, gists_url: https://api.github.com/users/github-actions%5Bbot%5D/
  │ gists{/gist_id}, starred_url: https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo},
  │ subscriptions_url: https://api.github.com/users/github-actions%5Bbot%5D/subscriptions, organizations_url: https://
  │ api.github.com/users/github-actions%5Bbot%5D/orgs, repos_url: https://api.github.com/users/github-actions%5Bbot%5D/
  │ repos, events_url: https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}, received_events_url: https://
  │ api.github.com/users/github-actions%5Bbot%5D/received_events, type: Bot, site_admin: false}, content_type: application/
  │ octet-stream, state: uploaded, size: 13238272, download_count: 0, created_at: 2023-10-13T01:50:02Z, updated_at: 2023-
  │ 10-13T01:50:03Z, browser_download_url: https://github.com/nushell/nightly/releases/download/nightly-c925537/nu-
  │ 0.85.1-aarch64-pc-windows-msvc.msi}, {url: https://api.github.com/repos/nushell/nightly/releases/assets/130351230,
  │ id: 130351230, node_id: RA_kwDOJuqqcM4HxQB-, name: nu-0.85.1-aarch64-pc-windows-msvc.zip, label: , uploader: {login:
  │ github-actions[bot], id: 41898282, node_id: MDM6Qm90NDE4OTgyODI=, avatar_url: https://avatars.githubusercontent.com/
  │ in/15368?v=4, gravatar_id: , url: https://api.github.com/users/github-actions%5Bbot%5D, html_url: https://github.com/
  │ apps/github-actions, followers_url: https://api.github.com/users/github-actions%5Bbot%5D/followers, following_url:
  │ https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}, gists_url: https://api.github.com/
  │ users/github-actions%5Bbot%5D/gists{/gist_id}, starred_url: https://api.github.com/users/github-actions%5Bbot%5D/
  │ starred{/owner}{/repo}, subscriptions_url: https://api.github.com/users/github-actions%5Bbot%5D/subscriptions,
  │ organizations_url: https://api.github.com/users/github-actions%5Bbot%5D/orgs, repos_url: https://api.github.com/users/
  │ github-actions%5Bbot%5D/repos, events_url: https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy},
  │ received_events_url: https://api.github.com/users/github-actions%5Bbot%5D/received_events, type: Bot, site_admin:
  │ false}, content_type: application/zip, state: uploaded, size: 16752897, download_count: 0, created_at: 2023-10-
  │ 13T01:48:24Z, updated_at: 2023-10-13T01:48:26Z, browser_download_url: https://github.com/nushell/nightly/releases/
  │ download/nightly-c925537/nu-0.85.1-aarch64-pc-windows-msvc.zip}]

Can we simplify the matches: .... message? It's too long I think

@amtoine amtoine deleted the download-script branch October 13, 2023 15:57
@amtoine
Copy link
Member Author

amtoine commented Oct 13, 2023

@hustcer
glad you like it 🙏

for the windows bug, i have no idea how to fix it and cannot test it 😢

hustcer pushed a commit that referenced this pull request Apr 11, 2025
Issue #12289, can be closed when this is merged

# Description
Currently, the ``into datetime`` command's signature indicates that it
supports input as record, but it was actually not supported.

This PR implements this feature.

# User-Facing Changes

``into datetime``'s signature changed (see comments)

**Happy paths**

Note: I'm in +02:00 timezone.

```nushell
> date now | into record | into datetime
Fri, 4 Apr 2025 18:32:34 +0200 (now)

> {year: 2025, month: 12, day: 6, second: 59} | into datetime | into record
╭─────────────┬────────╮
│ year        │ 2025   │
│ month       │ 12     │
│ day         │ 6      │
│ hour        │ 0      │
│ minute      │ 0      │
│ second      │ 59     │
│ millisecond │ 0      │
│ microsecond │ 0      │
│ nanosecond  │ 0      │
│ timezone    │ +02:00 │
╰─────────────┴────────╯

> {day: 6, second: 59, timezone: '-06:00'} | into datetime | into record
╭─────────────┬────────╮
│ year        │ 2025   │
│ month       │ 4      │
│ day         │ 6      │
│ hour        │ 0      │
│ minute      │ 0      │
│ second      │ 59     │
│ millisecond │ 0      │
│ microsecond │ 0      │
│ nanosecond  │ 0      │
│ timezone    │ -06:00 │
╰─────────────┴────────╯
```

**Edge cases**

```nushell
{} | into datetime
Fri, 4 Apr 2025 18:35:19 +0200 (now)
```

**Error paths**

- A key has a wrong type
  ```nushell
  > {month: 12, year: '2023'} | into datetime
  Error: nu::shell::only_supports_this_input_type

    × Input type not supported.
    ╭─[entry #8:1:19]
  1 │ {month: 12, year: '2023'} | into datetime
    ·                   ───┬──    ──────┬──────
· │ ╰── only int input data is supported
    ·                      ╰── input type: string
    ╰────
  ```
  ```nushell
  > {month: 12, year: 2023, timezone: 100} | into datetime
  Error: nu:🐚:only_supports_this_input_type

    × Input type not supported.
    ╭─[entry #10:1:35]
  1 │ {month: 12, year: 2023, timezone: 100} | into datetime
    ·                                   ─┬─    ──────┬──────
· │ ╰── only string input data is supported
    ·                                    ╰── input type: int
    ╰────
  ```
- Key has the right type but value invalid (e.g. month=13, or day=0)
  ```nushell
  > {month: 13, year: 2023} | into datetime
  Error: nu:🐚:incorrect_value

    × Incorrect value.
    ╭─[entry #9:1:1]
  1 │ {month: 13, year: 2023} | into datetime
    · ───────────┬───────────   ──────┬──────
· │ ╰── one of more values are incorrect and do not represent valid date
    ·            ╰── encountered here
    ╰────
  ```
  ```nushell
  > {hour: 1, minute: 1, second: 70} | into datetime
  Error: nu:🐚:incorrect_value
  
    × Incorrect value.
     ╭─[entry #3:1:1]
   1 │ {hour: 1, minute: 1, second: 70} | into datetime
     · ────────────────┬───────────────   ──────┬──────
· │ ╰── one of more values are incorrect and do not represent valid time
     ·                 ╰── encountered here
     ╰────
  ```
- Timezone has right type but is invalid
  ```nushell
  > {month: 12, year: 2023, timezone: "+100:00"} | into datetime
  Error: nu:🐚:incorrect_value

    × Incorrect value.
    ╭─[entry #11:1:35]
  1 │ {month: 12, year: 2023, timezone: "+100:00"} | into datetime
    ·                                   ────┬────    ──────┬──────
· │ ╰── encountered here
    ·                                       ╰── invalid timezone
    ╰────
  ```
- Record contains an invalid key
  ```nushell
  > {month: 12, year: 2023, unknown: 1} | into datetime
  Error: nu:🐚:unsupported_input

    × Unsupported input
    ╭─[entry #12:1:1]
  1 │ {month: 12, year: 2023, unknown: 1} | into datetime
    · ─────────────────┬─────────────────   ──────┬──────
· │ ╰── Column 'unknown' is not valid for a structured datetime. Allowed
columns are: year, month, day, hour, minute, second, millisecond,
microsecond, nanosecond, timezone
    ·                  ╰── value originates from here
    ╰────
  ```
- If several issues are present, the user can get the error msg for only
one, though
  ```nushell
  > {month: 20, year: '2023'} | into datetime
  Error: nu:🐚:only_supports_this_input_type

    × Input type not supported.
    ╭─[entry #7:1:19]
  1 │ {month: 20, year: '2023'} | into datetime
    ·                   ───┬──    ──────┬──────
· │ ╰── only int input data is supported
    ·                      ╰── input type: string
    ╰
  ```


# Tests + Formatting
Tests added
Fmt + clippy OK

# After Submitting
Maybe indicate that in the release notes
I added an example in the command, so the documentation will be
automatically updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants