# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.17.1

EAPI=8

CRATES="
    Inflector@0.11.4
    aho-corasick@1.1.5
    ansi_term@0.12.1
    anstream@1.0.0
    anstyle@1.0.14
    anstyle-parse@1.0.0
    anstyle-query@1.1.5
    anstyle-wincon@3.0.11
    anyhow@1.0.104
    assert_cmd@2.2.2
    async-trait@0.1.92
    autocfg@1.5.1
    bit-set@0.11.1
    bit-vec@0.10.1
    bitflags@2.13.1
    borrow-or-share@0.2.4
    borsh@1.8.0
    borsh-derive@1.8.0
    bstr@1.13.1
    bumpalo@3.20.3
    bytes@1.12.1
    cast@0.3.0
    cc@1.4.4
    cfg-if@1.0.4
    cfg_aliases@0.2.2
    clap@4.6.6
    clap_builder@4.6.6
    clap_complete@4.6.9
    clap_derive@4.6.4
    clap_lex@1.1.0
    codespan-reporting@0.13.1
    colorchoice@1.0.5
    convert_case@0.10.0
    convert_case@0.11.0
    coolor@1.1.0
    crokey@1.5.0
    crokey-proc_macros@1.5.0
    crossbeam@0.8.4
    crossbeam-channel@0.5.16
    crossbeam-deque@0.8.7
    crossbeam-epoch@0.9.20
    crossbeam-queue@0.3.13
    crossbeam-utils@0.8.22
    crossterm@0.29.0
    crossterm_winapi@0.9.1
    ctor@1.0.13
    dashmap@6.2.1
    derive_more@2.1.1
    derive_more-impl@2.1.1
    difflib@0.4.0
    document-features@0.2.12
    dyn-clone@1.0.20
    equivalent@1.0.2
    errno@0.3.14
    fastrand@2.5.0
    find-msvc-tools@0.1.11
    float-cmp@0.10.0
    fluent-uri@0.4.1
    fnv@1.0.7
    futures@0.3.34
    futures-channel@0.3.34
    futures-core@0.3.34
    futures-executor@0.3.34
    futures-io@0.3.34
    futures-macro@0.3.34
    futures-sink@0.3.34
    futures-task@0.3.34
    futures-util@0.3.34
    fuzzy-matcher@0.3.7
    getrandom@0.4.3
    globset@0.4.20
    hashbrown@0.14.5
    hashbrown@0.17.1
    heck@0.5.0
    httparse@1.10.1
    ignore@0.4.33
    indexmap@2.14.0
    inquire@0.9.4
    is_terminal_polyfill@1.70.2
    itoa@1.0.18
    js-sys@0.3.104
    lazy-regex@3.6.1
    lazy-regex-proc_macros@3.6.1
    lazy_static@1.5.0
    libc@0.2.189
    libloading@0.9.0
    libm@0.2.16
    linux-raw-sys@0.12.1
    litrs@1.0.0
    lock_api@0.4.14
    log@0.4.34
    ls-types@0.0.6
    matchers@0.2.0
    memchr@2.8.3
    minicov@0.3.9
    minimad@0.16.0
    mio@1.2.2
    napi@3.12.2
    napi-build@2.4.1
    napi-derive@3.6.3
    napi-derive-backend@6.1.2
    napi-sys@3.3.0
    nix@0.31.3
    nohash-hasher@0.2.0
    normalize-line-endings@0.3.0
    nu-ansi-term@0.50.3
    num-traits@0.2.19
    once_cell@1.21.4
    once_cell_polyfill@1.70.2
    oorandom@11.1.5
    parking_lot@0.12.5
    parking_lot_core@0.9.12
    percent-encoding@2.3.2
    pin-project-lite@0.2.17
    portable-atomic@1.15.0
    predicates@3.1.4
    predicates-core@1.0.10
    predicates-tree@1.0.13
    prettyplease@0.2.37
    proc-macro-crate@3.5.0
    proc-macro2@1.0.107
    pyo3@0.29.2
    pyo3-build-config@0.29.2
    pyo3-ffi@0.29.2
    pyo3-macros@0.29.2
    pyo3-macros-backend@0.29.2
    pythonize@0.29.0
    quote@1.0.47
    r-efi@6.0.0
    redox_syscall@0.5.18
    ref-cast@1.0.27
    ref-cast-impl@1.0.27
    regex@1.13.1
    regex-automata@0.4.18
    regex-syntax@0.8.11
    rustc-hash@2.1.3
    rustc_version@0.4.1
    rustix@1.1.4
    rustversion@1.0.23
    ryu@1.0.23
    same-file@1.0.6
    schemafy_core@0.6.0
    schemafy_lib@0.6.0
    schemars@1.2.2
    schemars_derive@1.2.2
    scopeguard@1.2.0
    semver@1.0.28
    serde@1.0.229
    serde-sarif@0.8.0
    serde-wasm-bindgen@0.6.5
    serde_core@1.0.229
    serde_derive@1.0.229
    serde_derive_internals@0.30.0
    serde_json@1.0.151
    serde_regex@1.2.0
    serde_yaml@0.9.34+deprecated
    sharded-slab@0.1.7
    shlex@2.0.1
    signal-hook@0.3.18
    signal-hook-mio@0.2.5
    signal-hook-registry@1.4.8
    similar@3.2.0
    slab@0.4.12
    smallvec@1.15.2
    streaming-iterator@0.1.9
    strict@0.2.0
    strsim@0.11.1
    strum@0.27.2
    strum_macros@0.27.2
    syn@1.0.109
    syn@2.0.119
    syn@3.0.3
    sync_wrapper@1.0.2
    target-lexicon@0.13.5
    target-triple@1.0.1
    tempfile@3.27.0
    termcolor@1.4.1
    termimad@0.35.2
    terminal-light@1.9.1
    termtree@0.5.1
    thiserror@1.0.69
    thiserror@2.0.20
    thiserror-impl@1.0.69
    thiserror-impl@2.0.20
    thread_local@1.1.10
    tokio@1.53.1
    tokio-macros@2.7.2
    tokio-stream@0.1.19
    tokio-util@0.7.19
    toml_datetime@1.1.1+spec-1.1.0
    toml_edit@0.25.13+spec-1.1.0
    toml_parser@1.1.3+spec-1.1.0
    toml_writer@1.1.2+spec-1.1.0
    tower@0.5.3
    tower-layer@0.3.3
    tower-lsp-server@0.23.0
    tower-service@0.3.3
    tracing@0.1.44
    tracing-attributes@0.1.31
    tracing-core@0.1.36
    tracing-log@0.2.0
    tracing-subscriber@0.3.23
    tree-sitter@0.27.0
    tree-sitter-bash@0.25.1
    tree-sitter-c@0.24.2
    tree-sitter-c-sharp@0.23.5
    tree-sitter-cpp@0.23.4
    tree-sitter-css@0.25.0
    tree-sitter-dart@0.2.0
    tree-sitter-elixir@0.3.5
    tree-sitter-go@0.25.0
    tree-sitter-haskell@0.23.1
    tree-sitter-hcl@1.1.0
    tree-sitter-html@0.23.2
    tree-sitter-java@0.23.5
    tree-sitter-javascript@0.25.0
    tree-sitter-json@0.24.8
    tree-sitter-kotlin-sg@0.4.1
    tree-sitter-language@0.1.8
    tree-sitter-lua@0.5.0
    tree-sitter-md@0.5.3
    tree-sitter-nix@0.3.0
    tree-sitter-php@0.24.2
    tree-sitter-python@0.25.0
    tree-sitter-ruby@0.23.1
    tree-sitter-rust@0.24.2
    tree-sitter-scala@0.26.2
    tree-sitter-solidity@1.2.13
    tree-sitter-swift@0.7.3
    tree-sitter-typescript@0.23.2
    tree-sitter-yaml@0.7.2
    typed-builder@0.21.2
    typed-builder-macro@0.21.2
    unicode-ident@1.0.24
    unicode-segmentation@1.13.3
    unicode-width@0.1.14
    unicode-width@0.2.2
    unsafe-libyaml@0.2.11
    uriparse@0.6.4
    utf8parse@0.2.2
    valuable@0.1.1
    wait-timeout@0.2.1
    walkdir@2.5.0
    wasi@0.11.1+wasi-snapshot-preview1
    wasm-bindgen@0.2.127
    wasm-bindgen-futures@0.4.77
    wasm-bindgen-macro@0.2.127
    wasm-bindgen-macro-support@0.2.127
    wasm-bindgen-shared@0.2.127
    wasm-bindgen-test@0.3.77
    wasm-bindgen-test-macro@0.3.77
    wasm-bindgen-test-shared@0.2.127
    winapi@0.3.9
    winapi-i686-pc-windows-gnu@0.4.0
    winapi-util@0.1.11
    winapi-x86_64-pc-windows-gnu@0.4.0
    windows-link@0.2.1
    windows-sys@0.59.0
    windows-sys@0.61.2
    windows-targets@0.52.6
    windows_aarch64_gnullvm@0.52.6
    windows_aarch64_msvc@0.52.6
    windows_i686_gnu@0.52.6
    windows_i686_gnullvm@0.52.6
    windows_i686_msvc@0.52.6
    windows_x86_64_gnu@0.52.6
    windows_x86_64_gnullvm@0.52.6
    windows_x86_64_msvc@0.52.6
    winnow@1.0.4
    xterm-query@0.6.0
    zmij@1.0.23
"

RUST_MIN_VER="1.88.0"

inherit cargo shell-completion

DESCRIPTION="Search and rewrite code at large scale using precise AST patterns"
HOMEPAGE="
	https://ast-grep.github.io/
	https://github.com/ast-grep/ast-grep
"
SRC_URI="
	https://github.com/ast-grep/ast-grep/archive/refs/tags/${PV}.tar.gz -> ${P}.gh.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 ISC MIT MIT-0
	Unicode-3.0
"
SLOT="0"
KEYWORDS="~amd64 ~arm64"

QA_FLAGS_IGNORED="usr/bin/ast-grep"

src_compile() {
	cargo_src_compile --package ast-grep --bin ast-grep

	local bin="$(cargo_target_dir)/ast-grep"
	"${bin}" completions bash > ast-grep.bash || die
	"${bin}" completions zsh > _ast-grep || die
	"${bin}" completions fish > ast-grep.fish || die
}

src_test() {
	cargo_src_test --package ast-grep --package ast-grep-core \
		--package ast-grep-config --package ast-grep-language
}

src_install() {
	# Das "sg"-Alias-Binary wird bewusst nicht installiert:
	# es kollidiert mit /usr/bin/sg aus sys-apps/shadow.
	dobin "$(cargo_target_dir)/ast-grep"

	newbashcomp ast-grep.bash ast-grep
	dozshcomp _ast-grep
	dofishcomp ast-grep.fish

	einstalldocs
}