Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored and fredrikekre committed Nov 7, 2024
1 parent 1d399ba commit 0bc346a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 7 deletions.
62 changes: 62 additions & 0 deletions docs/src/apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# [**?.** Apps](@id Apps)

!!! note
The app support in Pkg is currently considered experimental and some functionality and API may change.

Apps are Julia packages that are intended to be run as a "standalone programs" (by e.g. typing the name of the app in the terminal possibly together with some arguments or flags/options).
This is in contrast to most Julia packages that are used as "libraries" and are loaded by other files or in the Julia REPL.

## Creating a Julia app

A Julia app is structured similar to a standard Julia library with the following additions:

- A `@main` entry point in the package module (see the Julia help on `@main` for details)
- An `[app]` section in the `Project.toml` file listing the executable names that the package provides.

A very simple example of an app that prints the reversed input arguments would be:

```julia
# src/MyReverseApp.jl
module MyReverseApp

function (@main)(ARGS)
for arg in ARGS
print(stdout, reverse(arg), " ")
end
return
end

end # module
```

```toml
# Project.toml

...

[apps]
reverse = {}
```

The empty table `{}` is to allow for giving metadata about the app but it is currently unused.

After installing this app one could run:

```
$ reverse some input string
emos tupni gnirts
```

## Installing Julia apps

The installation of Julia apps are similar to installing julia libraries but instead of using e.g. `Pkg.add` or `pkg> add` one uses `Pkg.Apps.add` or `pkg> app add`.

!!! note
The path `.julia/bin` has to be added to your `PATH` in order for



## Other information

- The app will currently run with the same Julia executable as was used to install the app. To update the Julia executable used run...
-
23 changes: 16 additions & 7 deletions src/Apps/Apps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,21 @@ function develop(pkg::String)
develop(PackageSpec(pkg))
end

function develop(pkg::Vector{PackageSpec})
for p in pkg
develop(p)
end
end

function develop(pkg::PackageSpec)
if pkg.path !== nothing
pkg.path == abspath(pkg.path)
end
handle_package_input!(pkg)
ctx = app_context()

handle_repo_develop!(ctx, pkg, #=shared =# true)


project = handle_project_file(pkg.path)
sourcepath = abspath(source_path(ctx.env.manifest_file, pkg))
project = handle_project_file(sourcepath)

# Seems like the `.repo.source` field is not cleared.
# At least repo-url is still in the manifest after doing a dev with a path
Expand All @@ -164,9 +171,9 @@ function develop(pkg::PackageSpec)
pkg.repo.source = nothing
end

entry = PackageEntry(;apps = project.apps, name = pkg.name, version = project.version, tree_hash = pkg.tree_hash, path = pkg.path, repo = pkg.repo, uuid=pkg.uuid)
entry = PackageEntry(;apps = project.apps, name = pkg.name, version = project.version, tree_hash = pkg.tree_hash, path = sourcepath, repo = pkg.repo, uuid=pkg.uuid)
update_app_manifest(entry)
generate_shims_for_apps(entry.name, entry.apps, entry.path)
generate_shims_for_apps(entry.name, entry.apps, sourcepath)
end

function status(pkgs_or_apps::Vector)
Expand Down Expand Up @@ -265,7 +272,9 @@ function rm(pkg_or_app::Union{PackageSpec, Nothing}=nothing)
@info "Deleted $(appname)"
rm_shim(appname; force=true)
end
Base.rm(joinpath(APP_ENV_FOLDER, dep.name); recursive=true)
if dep.path === nothing
Base.rm(joinpath(APP_ENV_FOLDER, dep.name); recursive=true)
end
else
for (uuid, pkg) in manifest.deps
app_idx = findfirst(app -> app.name == pkg_or_app, pkg.apps)
Expand Down

0 comments on commit 0bc346a

Please sign in to comment.