Replace all repository topics.
var setTopics = require( '@stdlib/_tools/github/set-topics' );Replaces all topics of a repository corresponding to a provided repository slug (:owner/:repo).
var opts = {
'token': 'tkjorjk34ek3nj4!'
};
setTopics( 'math-io/erf', [ 'math', 'special' ], opts, clbk );
function clbk( error, data, info ) {
// Check for rate limit information...
if ( info ) {
console.error( 'Limit: %d', info.limit );
console.error( 'Remaining: %d', info.remaining );
console.error( 'Reset: %s', (new Date( info.reset*1000 )).toISOString() );
}
if ( error ) {
throw new Error( error.message );
}
console.log( data );
}The function accepts the following options:
- token: GitHub access token (required).
- useragent: user agent
string.
To authenticate with GitHub, set the token option.
var opts = {
'token': 'tkjorjk34ek3nj4!'
};
setTopics( 'math-io/erf', [ 'math', 'special' ], opts, clbk );To specify a user agent, set the useragent option.
var opts = {
'token': 'tkjorjk34ek3nj4!',
'useragent': 'hello-github!'
};
setTopics( 'kgryte/utils-deep-set', [ 'utils', 'setter' ], opts, clbk );Creates a reusable function.
var opts = {
'token': 'tkjorjk34ek3nj4!',
'useragent': 'hello-github!'
};
var topics = setTopics.factory( opts, clbk );
topics( 'math-io/erf', [ 'math', 'special' ] );
// ...The factory method accepts the same options as setTopics().
var setTopics = require( '@stdlib/_tools/github/set-topics' );
var opts = {
'token': '<your_token_goes_here>',
'useragent': 'beep-boop-bop'
};
setTopics( 'math-io/erf', [ 'math', 'special' ], opts, clbk );
function clbk( error, data, info ) {
if ( info ) {
console.error( info );
}
if ( error ) {
if ( error instanceof Error ) {
throw error;
}
console.error( error.message );
} else {
console.log( data );
}
}Note: in order to run the example, you will need to obtain an access token with appropriate permissions and modify the token option accordingly.
Usage: ghtopics [options] slug <topic1>,<topic2>,...
Options:
-h, --help Print this message.
-V, --version Print the package version.
--token token GitHub access token.
-ua, --useragent ua User agent.- In addition to the
tokenoption, the token may also be specified by aGITHUB_TOKENenvironment variable. The command-line option always takes precedence. - Rate limit information is written to
stderr.
Setting the access token using the command-line option:
$ DEBUG=* ghtopics --token <token> math-io/gammaln math,special
# => 'Set topics for math-io/gammaln.'Setting the access token using an environment variable:
$ DEBUG=* GITHUB_TOKEN=<token> ghtopics kgryte/utils-copy math,special
# => 'Set topics for kgryte/utils-copy.'