Comments (9)
Hi @tartale,
You can already use jfrog-cli-go as a library and we would love to see it embedded in other applications. We made sure to keep the commands code separated from the CLI code, so that you can invoke the commands from your go application, the same way the CLI code does. Look at the cli.go files. You'll notice that only they are CLI related. Your code can invoke the commands the same way.
from jfrog-cli.
Thanks for the quick reply! I'm actually currently doing this, and found that, if you use the commands code as an entry point, it mostly works, with one exception - if the command you're calling experiences an error, the command doesn't return an error - it actually panics due to the assumption that the CLI library (codegansta) was initialized.
If you guys weren't interested in splitting the library out, another possibility would be to update to the latest of the codegansta/cli (moved to urfave/cli) allows the command function to return an error.
Here's an example of a code snippet that would cause a panic:
import (
"github.com/jfrogdev/jfrog-cli-go/artifactory/commands"
"github.com/jfrogdev/jfrog-cli-go/artifactory/utils"
"github.com/jfrogdev/jfrog-cli-go/utils/config"
)
var ARTIFACTORY_CONF *config.ArtifactoryDetails = &config.ArtifactoryDetails{
Url: "http://website.com/artifactory", // notice the missing trailing /
User: "admin",
Password: "foo",
}
downloadFlags := utils.Flags{
ArtDetails: ARTIFACTORY_CONF,
}
commands.Download("repo/*jre.rpm", &downloadFlags)
// ^^ this panics, because I must either provide a trailing / for the Url
// or a preceding / for the specification.
// A returned error would be easier to work with
from jfrog-cli.
Thanks for pointing out this issue @tartale. We'll modify the commands API so that all commands return an error instead of throwing a panic. We'll let you know when done.
from jfrog-cli.
@tartale, just updating that we've already started working on modifying code, so that all APIs return an error, rather than exiting, when the packages is used as a library.
from jfrog-cli.
@eyalbe4 Great to hear - thank you!
from jfrog-cli.
@tartale, we pushed the code into the dev branch. It might still change a bit before the next release, but you can already look at it.
from jfrog-cli.
@tartale, JFrog CLI 1.5.0 includes this change. It does not exit when used as a library.
from jfrog-cli.
@eyalbe4 Thank you! I'll try it out
from jfrog-cli.
@tartale, I'm closing this issue for now. When you get a chance to use the APIs, we'd appreciate your feedback.
from jfrog-cli.
Related Issues (20)
- Support providing a NuGet config file using /p:RestoreConfigFile
- jf scan does not order/sort results consistently HOT 1
- Jfrog Artifactory move and copy commands - flat flag default value HOT 1
- Currently the CLI only has a create replication command and is lacking the update command.
- jf docker scan does not work with Docker Engine 25 and above HOT 2
- jf cli limited to 255 characters during debian upload HOT 1
- Possible memory leak or extensive usage of in memory manipulations when running `jf yarn install` on larger projects with node-gyp HOT 1
- Get list of builds for an artifact HOT 1
- Release Bundle Create command (jf rbc) has an issue with the --project flag when using a spec file that is not "builds" but "pattern" or "aql" HOT 2
- Issues using `--archive=zip` flag in the upload command
- jf docker scan ubuntu:latest fails,
- Download from maven-central fails for plugins when resolving release repository with Jfrog CLI HOT 3
- jf poetry publish -> Unsupported Media Type HOT 1
- Create the access token with the new access api endpoint instead of old artifactory endpoint when CLI is configured with username and password HOT 1
- jfrog cli panics when no default config is defined HOT 1
- Jfrog yarn install vs yarn install
- Cannot complete the `jf mvn-config` wizard HOT 2
- Suppressing GOMAXPROCS in info log HOT 2
- 2.58.1 fails to install on el7 distributions HOT 6
- Hope the JFrog CLI support the third-party provider tokens for authentication HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jfrog-cli.